{"action":"created","comment":{"url":"https://api.github.com/repos/bcgov/secure-image-api/pulls/comments/167347999","pull_request_review_id":95564622,"id":167347999,"diff_hunk":"@@ -0,0 +1,95 @@\n+//\n+// SecureImage\n+//\n+// Copyright \u0003© 2018 Province of British Columbia\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+//\n+// Created by Jason Leach on 2018-02-01.\n+//\n+\n+/* eslint-env es6 */\n+\n+'use strict';\n+\n+import request from 'request';\n+import jwt from 'jsonwebtoken';\n+import pemFromModAndExponent from 'rsa-pem-from-mod-exp';\n+\n+const verifyToken = clientAccessToken => new Promise((resolve, reject) => {\n+  request.get('https://dev-sso.pathfinder.gov.bc.ca/auth/realms/mobile/protocol/openid-connect/certs', {\n+\n+  }, (err, res, certsBody) => {\n+    if (err) {\n+      reject(err);\n+      return;\n+    }\n+\n+    const certsJson = JSON.parse(certsBody).keys[0];\n+\n+    const modulus = certsJson.n;\n+    const exponent = certsJson.e;\n+    const algorithm = certsJson.alg;\n+\n+    if (!modulus) {\n+      reject(new Error('No modulus'));\n+      return;\n+    }\n+\n+    if (!exponent) {\n+      reject(new Error('No exponent'));\n+      return;\n+    }\n+\n+    if (!algorithm) {\n+      reject(new Error('No algorithm'));\n+      return;\n+    }\n+\n+    // build a certificate\n+    const pem = pemFromModAndExponent(modulus, exponent);\n+\n+    // verify\n+    jwt.verify(clientAccessToken, pem, { algorithms: [algorithm] }, (verifyErr, verifyResult) => {\n+      if (verifyErr) {\n+        reject(verifyErr);\n+        return;\n+      }\n+      resolve(verifyResult);\n+    });\n+  });\n+});\n+\n+function sendError(res, statusCode, message) {","path":"server/libs/auth.js","position":73,"original_position":73,"commit_id":"ecd4493ccacaf431d1e0de7bbb00efb47000711b","original_commit_id":"ecd4493ccacaf431d1e0de7bbb00efb47000711b","user":{"login":"jleach","id":390891,"avatar_url":"https://avatars0.githubusercontent.com/u/390891?v=4","gravatar_id":"","url":"https://api.github.com/users/jleach","html_url":"https://github.com/jleach","followers_url":"https://api.github.com/users/jleach/followers","following_url":"https://api.github.com/users/jleach/following{/other_user}","gists_url":"https://api.github.com/users/jleach/gists{/gist_id}","starred_url":"https://api.github.com/users/jleach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jleach/subscriptions","organizations_url":"https://api.github.com/users/jleach/orgs","repos_url":"https://api.github.com/users/jleach/repos","events_url":"https://api.github.com/users/jleach/events{/privacy}","received_events_url":"https://api.github.com/users/jleach/received_events","type":"User","site_admin":false},"body":"Lets put the non-exported functions all together at the top or bottom for rather than salt and peppering them in between the exports.","created_at":"2018-02-09T21:17:11Z","updated_at":"2018-02-09T21:20:32Z","html_url":"https://github.com/bcgov/secure-image-api/pull/1#discussion_r167347999","pull_request_url":"https://api.github.com/repos/bcgov/secure-image-api/pulls/1","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/bcgov/secure-image-api/pulls/comments/167347999"},"html":{"href":"https://github.com/bcgov/secure-image-api/pull/1#discussion_r167347999"},"pull_request":{"href":"https://api.github.com/repos/bcgov/secure-image-api/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/bcgov/secure-image-api/pulls/1","id":168342483,"html_url":"https://github.com/bcgov/secure-image-api/pull/1","diff_url":"https://github.com/bcgov/secure-image-api/pull/1.diff","patch_url":"https://github.com/bcgov/secure-image-api/pull/1.patch","issue_url":"https://api.github.com/repos/bcgov/secure-image-api/issues/1","number":1,"state":"open","locked":false,"title":"Auth","user":{"login":"AidanLaing","id":17442696,"avatar_url":"https://avatars1.githubusercontent.com/u/17442696?v=4","gravatar_id":"","url":"https://api.github.com/users/AidanLaing","html_url":"https://github.com/AidanLaing","followers_url":"https://api.github.com/users/AidanLaing/followers","following_url":"https://api.github.com/users/AidanLaing/following{/other_user}","gists_url":"https://api.github.com/users/AidanLaing/gists{/gist_id}","starred_url":"https://api.github.com/users/AidanLaing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AidanLaing/subscriptions","organizations_url":"https://api.github.com/users/AidanLaing/orgs","repos_url":"https://api.github.com/users/AidanLaing/repos","events_url":"https://api.github.com/users/AidanLaing/events{/privacy}","received_events_url":"https://api.github.com/users/AidanLaing/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-02-09T21:07:31Z","updated_at":"2018-02-09T21:20:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"17efd6052e6dc5769c5e580043a73bff4a60500f","assignee":{"login":"AidanLaing","id":17442696,"avatar_url":"https://avatars1.githubusercontent.com/u/17442696?v=4","gravatar_id":"","url":"https://api.github.com/users/AidanLaing","html_url":"https://github.com/AidanLaing","followers_url":"https://api.github.com/users/AidanLaing/followers","following_url":"https://api.github.com/users/AidanLaing/following{/other_user}","gists_url":"https://api.github.com/users/AidanLaing/gists{/gist_id}","starred_url":"https://api.github.com/users/AidanLaing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AidanLaing/subscriptions","organizations_url":"https://api.github.com/users/AidanLaing/orgs","repos_url":"https://api.github.com/users/AidanLaing/repos","events_url":"https://api.github.com/users/AidanLaing/events{/privacy}","received_events_url":"https://api.github.com/users/AidanLaing/received_events","type":"User","site_admin":false},"assignees":[{"login":"AidanLaing","id":17442696,"avatar_url":"https://avatars1.githubusercontent.com/u/17442696?v=4","gravatar_id":"","url":"https://api.github.com/users/AidanLaing","html_url":"https://github.com/AidanLaing","followers_url":"https://api.github.com/users/AidanLaing/followers","following_url":"https://api.github.com/users/AidanLaing/following{/other_user}","gists_url":"https://api.github.com/users/AidanLaing/gists{/gist_id}","starred_url":"https://api.github.com/users/AidanLaing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AidanLaing/subscriptions","organizations_url":"https://api.github.com/users/AidanLaing/orgs","repos_url":"https://api.github.com/users/AidanLaing/repos","events_url":"https://api.github.com/users/AidanLaing/events{/privacy}","received_events_url":"https://api.github.com/users/AidanLaing/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/bcgov/secure-image-api/pulls/1/commits","review_comments_url":"https://api.github.com/repos/bcgov/secure-image-api/pulls/1/comments","review_comment_url":"https://api.github.com/repos/bcgov/secure-image-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bcgov/secure-image-api/issues/1/comments","statuses_url":"https://api.github.com/repos/bcgov/secure-image-api/statuses/ecd4493ccacaf431d1e0de7bbb00efb47000711b","head":{"label":"bcgov:auth","ref":"auth","sha":"ecd4493ccacaf431d1e0de7bbb00efb47000711b","user":{"login":"bcgov","id":916280,"avatar_url":"https://avatars1.githubusercontent.com/u/916280?v=4","gravatar_id":"","url":"https://api.github.com/users/bcgov","html_url":"https://github.com/bcgov","followers_url":"https://api.github.com/users/bcgov/followers","following_url":"https://api.github.com/users/bcgov/following{/other_user}","gists_url":"https://api.github.com/users/bcgov/gists{/gist_id}","starred_url":"https://api.github.com/users/bcgov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcgov/subscriptions","organizations_url":"https://api.github.com/users/bcgov/orgs","repos_url":"https://api.github.com/users/bcgov/repos","events_url":"https://api.github.com/users/bcgov/events{/privacy}","received_events_url":"https://api.github.com/users/bcgov/received_events","type":"Organization","site_admin":false},"repo":{"id":114160345,"name":"secure-image-api","full_name":"bcgov/secure-image-api","owner":{"login":"bcgov","id":916280,"avatar_url":"https://avatars1.githubusercontent.com/u/916280?v=4","gravatar_id":"","url":"https://api.github.com/users/bcgov","html_url":"https://github.com/bcgov","followers_url":"https://api.github.com/users/bcgov/followers","following_url":"https://api.github.com/users/bcgov/following{/other_user}","gists_url":"https://api.github.com/users/bcgov/gists{/gist_id}","starred_url":"https://api.github.com/users/bcgov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcgov/subscriptions","organizations_url":"https://api.github.com/users/bcgov/orgs","repos_url":"https://api.github.com/users/bcgov/repos","events_url":"https://api.github.com/users/bcgov/events{/privacy}","received_events_url":"https://api.github.com/users/bcgov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bcgov/secure-image-api","description":"API for mobile secure image app","fork":false,"url":"https://api.github.com/repos/bcgov/secure-image-api","forks_url":"https://api.github.com/repos/bcgov/secure-image-api/forks","keys_url":"https://api.github.com/repos/bcgov/secure-image-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bcgov/secure-image-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bcgov/secure-image-api/teams","hooks_url":"https://api.github.com/repos/bcgov/secure-image-api/hooks","issue_events_url":"https://api.github.com/repos/bcgov/secure-image-api/issues/events{/number}","events_url":"https://api.github.com/repos/bcgov/secure-image-api/events","assignees_url":"https://api.github.com/repos/bcgov/secure-image-api/assignees{/user}","branches_url":"https://api.github.com/repos/bcgov/secure-image-api/branches{/branch}","tags_url":"https://api.github.com/repos/bcgov/secure-image-api/tags","blobs_url":"https://api.github.com/repos/bcgov/secure-image-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bcgov/secure-image-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bcgov/secure-image-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/bcgov/secure-image-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bcgov/secure-image-api/statuses/{sha}","languages_url":"https://api.github.com/repos/bcgov/secure-image-api/languages","stargazers_url":"https://api.github.com/repos/bcgov/secure-image-api/stargazers","contributors_url":"https://api.github.com/repos/bcgov/secure-image-api/contributors","subscribers_url":"https://api.github.com/repos/bcgov/secure-image-api/subscribers","subscription_url":"https://api.github.com/repos/bcgov/secure-image-api/subscription","commits_url":"https://api.github.com/repos/bcgov/secure-image-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/bcgov/secure-image-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/bcgov/secure-image-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/bcgov/secure-image-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/bcgov/secure-image-api/contents/{+path}","compare_url":"https://api.github.com/repos/bcgov/secure-image-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bcgov/secure-image-api/merges","archive_url":"https://api.github.com/repos/bcgov/secure-image-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bcgov/secure-image-api/downloads","issues_url":"https://api.github.com/repos/bcgov/secure-image-api/issues{/number}","pulls_url":"https://api.github.com/repos/bcgov/secure-image-api/pulls{/number}","milestones_url":"https://api.github.com/repos/bcgov/secure-image-api/milestones{/number}","notifications_url":"https://api.github.com/repos/bcgov/secure-image-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bcgov/secure-image-api/labels{/name}","releases_url":"https://api.github.com/repos/bcgov/secure-image-api/releases{/id}","deployments_url":"https://api.github.com/repos/bcgov/secure-image-api/deployments","created_at":"2017-12-13T19:25:21Z","updated_at":"2018-02-09T21:16:05Z","pushed_at":"2018-02-09T21:07:32Z","git_url":"git://github.com/bcgov/secure-image-api.git","ssh_url":"git@github.com:bcgov/secure-image-api.git","clone_url":"https://github.com/bcgov/secure-image-api.git","svn_url":"https://github.com/bcgov/secure-image-api","homepage":null,"size":526,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"bcgov:develop","ref":"develop","sha":"b7bf41c54ee2d4802907886ed5e213864e498a02","user":{"login":"bcgov","id":916280,"avatar_url":"https://avatars1.githubusercontent.com/u/916280?v=4","gravatar_id":"","url":"https://api.github.com/users/bcgov","html_url":"https://github.com/bcgov","followers_url":"https://api.github.com/users/bcgov/followers","following_url":"https://api.github.com/users/bcgov/following{/other_user}","gists_url":"https://api.github.com/users/bcgov/gists{/gist_id}","starred_url":"https://api.github.com/users/bcgov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcgov/subscriptions","organizations_url":"https://api.github.com/users/bcgov/orgs","repos_url":"https://api.github.com/users/bcgov/repos","events_url":"https://api.github.com/users/bcgov/events{/privacy}","received_events_url":"https://api.github.com/users/bcgov/received_events","type":"Organization","site_admin":false},"repo":{"id":114160345,"name":"secure-image-api","full_name":"bcgov/secure-image-api","owner":{"login":"bcgov","id":916280,"avatar_url":"https://avatars1.githubusercontent.com/u/916280?v=4","gravatar_id":"","url":"https://api.github.com/users/bcgov","html_url":"https://github.com/bcgov","followers_url":"https://api.github.com/users/bcgov/followers","following_url":"https://api.github.com/users/bcgov/following{/other_user}","gists_url":"https://api.github.com/users/bcgov/gists{/gist_id}","starred_url":"https://api.github.com/users/bcgov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcgov/subscriptions","organizations_url":"https://api.github.com/users/bcgov/orgs","repos_url":"https://api.github.com/users/bcgov/repos","events_url":"https://api.github.com/users/bcgov/events{/privacy}","received_events_url":"https://api.github.com/users/bcgov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bcgov/secure-image-api","description":"API for mobile secure image app","fork":false,"url":"https://api.github.com/repos/bcgov/secure-image-api","forks_url":"https://api.github.com/repos/bcgov/secure-image-api/forks","keys_url":"https://api.github.com/repos/bcgov/secure-image-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bcgov/secure-image-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bcgov/secure-image-api/teams","hooks_url":"https://api.github.com/repos/bcgov/secure-image-api/hooks","issue_events_url":"https://api.github.com/repos/bcgov/secure-image-api/issues/events{/number}","events_url":"https://api.github.com/repos/bcgov/secure-image-api/events","assignees_url":"https://api.github.com/repos/bcgov/secure-image-api/assignees{/user}","branches_url":"https://api.github.com/repos/bcgov/secure-image-api/branches{/branch}","tags_url":"https://api.github.com/repos/bcgov/secure-image-api/tags","blobs_url":"https://api.github.com/repos/bcgov/secure-image-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bcgov/secure-image-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bcgov/secure-image-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/bcgov/secure-image-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bcgov/secure-image-api/statuses/{sha}","languages_url":"https://api.github.com/repos/bcgov/secure-image-api/languages","stargazers_url":"https://api.github.com/repos/bcgov/secure-image-api/stargazers","contributors_url":"https://api.github.com/repos/bcgov/secure-image-api/contributors","subscribers_url":"https://api.github.com/repos/bcgov/secure-image-api/subscribers","subscription_url":"https://api.github.com/repos/bcgov/secure-image-api/subscription","commits_url":"https://api.github.com/repos/bcgov/secure-image-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/bcgov/secure-image-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/bcgov/secure-image-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/bcgov/secure-image-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/bcgov/secure-image-api/contents/{+path}","compare_url":"https://api.github.com/repos/bcgov/secure-image-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bcgov/secure-image-api/merges","archive_url":"https://api.github.com/repos/bcgov/secure-image-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bcgov/secure-image-api/downloads","issues_url":"https://api.github.com/repos/bcgov/secure-image-api/issues{/number}","pulls_url":"https://api.github.com/repos/bcgov/secure-image-api/pulls{/number}","milestones_url":"https://api.github.com/repos/bcgov/secure-image-api/milestones{/number}","notifications_url":"https://api.github.com/repos/bcgov/secure-image-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bcgov/secure-image-api/labels{/name}","releases_url":"https://api.github.com/repos/bcgov/secure-image-api/releases{/id}","deployments_url":"https://api.github.com/repos/bcgov/secure-image-api/deployments","created_at":"2017-12-13T19:25:21Z","updated_at":"2018-02-09T21:16:05Z","pushed_at":"2018-02-09T21:07:32Z","git_url":"git://github.com/bcgov/secure-image-api.git","ssh_url":"git@github.com:bcgov/secure-image-api.git","clone_url":"https://github.com/bcgov/secure-image-api.git","svn_url":"https://github.com/bcgov/secure-image-api","homepage":null,"size":526,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bcgov/secure-image-api/pulls/1"},"html":{"href":"https://github.com/bcgov/secure-image-api/pull/1"},"issue":{"href":"https://api.github.com/repos/bcgov/secure-image-api/issues/1"},"comments":{"href":"https://api.github.com/repos/bcgov/secure-image-api/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/bcgov/secure-image-api/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/bcgov/secure-image-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bcgov/secure-image-api/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/bcgov/secure-image-api/statuses/ecd4493ccacaf431d1e0de7bbb00efb47000711b"}},"author_association":"NONE"}}
{"actor":{"display_login":"jleach"}}