{"action":"created","comment":{"url":"https://api.github.com/repos/joyent/node-http-signature/pulls/comments/207253008","pull_request_review_id":142826626,"id":207253008,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNzI1MzAwOA==","diff_hunk":"@@ -73,7 +73,22 @@ module.exports = {\n     h1.update(hmac.digest());\n     h1 = h1.digest();\n     var h2 = crypto.createHmac(hashAlg, secret);\n-    h2.update(new Buffer(parsedSignature.params.signature, 'base64'));\n+\n+    var signatureBase64 = parsedSignature.params.signature;\n+    var signatureBuffer;\n+    if (Buffer.from && Buffer.from !== Uint8Array.from) {\n+      // Node.js 4.5.0 and newer\n+      signatureBuffer = Buffer.from(signatureBase64, 'base64');\n+    } else {\n+      // Node.js <4.5.0 || >=5.0.0 <5.10.0\n+      if (typeof signatureBase64 === 'number') {","path":"lib/verify.js","position":13,"original_position":13,"commit_id":"d4dbd7093bdc502ce2f92920e9bc470f8bd723b8","original_commit_id":"d4dbd7093bdc502ce2f92920e9bc470f8bd723b8","user":{"login":"jacobq","id":1633459,"node_id":"MDQ6VXNlcjE2MzM0NTk=","avatar_url":"https://avatars3.githubusercontent.com/u/1633459?v=4","gravatar_id":"","url":"https://api.github.com/users/jacobq","html_url":"https://github.com/jacobq","followers_url":"https://api.github.com/users/jacobq/followers","following_url":"https://api.github.com/users/jacobq/following{/other_user}","gists_url":"https://api.github.com/users/jacobq/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobq/subscriptions","organizations_url":"https://api.github.com/users/jacobq/orgs","repos_url":"https://api.github.com/users/jacobq/repos","events_url":"https://api.github.com/users/jacobq/events{/privacy}","received_events_url":"https://api.github.com/users/jacobq/received_events","type":"User","site_admin":false},"body":"OK, so, IIUC, the rationale for pushing the check down into the fall-back code is that it makes it more obvious that it can be removed when the fall-back code is removed. I guess that makes sense.","created_at":"2018-08-02T14:41:49Z","updated_at":"2018-08-02T14:41:49Z","html_url":"https://github.com/joyent/node-http-signature/pull/67#discussion_r207253008","pull_request_url":"https://api.github.com/repos/joyent/node-http-signature/pulls/67","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/joyent/node-http-signature/pulls/comments/207253008"},"html":{"href":"https://github.com/joyent/node-http-signature/pull/67#discussion_r207253008"},"pull_request":{"href":"https://api.github.com/repos/joyent/node-http-signature/pulls/67"}},"in_reply_to_id":207227129},"pull_request":{"url":"https://api.github.com/repos/joyent/node-http-signature/pulls/67","id":172587036,"node_id":"MDExOlB1bGxSZXF1ZXN0MTcyNTg3MDM2","html_url":"https://github.com/joyent/node-http-signature/pull/67","diff_url":"https://github.com/joyent/node-http-signature/pull/67.diff","patch_url":"https://github.com/joyent/node-http-signature/pull/67.patch","issue_url":"https://api.github.com/repos/joyent/node-http-signature/issues/67","number":67,"state":"open","locked":false,"title":"Avoid using deprecated Buffer API on newer Node.js","user":{"login":"ChALkeR","id":291301,"node_id":"MDQ6VXNlcjI5MTMwMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/291301?v=4","gravatar_id":"","url":"https://api.github.com/users/ChALkeR","html_url":"https://github.com/ChALkeR","followers_url":"https://api.github.com/users/ChALkeR/followers","following_url":"https://api.github.com/users/ChALkeR/following{/other_user}","gists_url":"https://api.github.com/users/ChALkeR/gists{/gist_id}","starred_url":"https://api.github.com/users/ChALkeR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChALkeR/subscriptions","organizations_url":"https://api.github.com/users/ChALkeR/orgs","repos_url":"https://api.github.com/users/ChALkeR/repos","events_url":"https://api.github.com/users/ChALkeR/events{/privacy}","received_events_url":"https://api.github.com/users/ChALkeR/received_events","type":"User","site_admin":false},"body":"This avoids using Buffer constructor API on newer Node.js versions.\r\n\r\nTo achieve that, `Buffer.from` presence is checked, with validation that it's not the same method as Uint8Array.from.\r\n\r\nAlso an additional type-guard is added in the fallback code path to ensure that typed numbers are never accidently fed into `new Buffer` input.\r\n\r\nGiven this module popularity and the fact that old Buffer constructor API was used in a single place, I decided to just feature-detect it in-place instead of pulling in polyfill deps.\r\nAnother way would be to just use `Buffer.from` and do `var Buffer = require('safe-buffer')`;\r\n\r\nRefs:\r\nhttps://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor\r\nTracking:\r\nhttps://github.com/nodejs/node/issues/19079","created_at":"2018-03-02T19:39:55Z","updated_at":"2018-08-02T14:41:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8d548e927fc90713872a1eea1be61ecd57578ed","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/joyent/node-http-signature/pulls/67/commits","review_comments_url":"https://api.github.com/repos/joyent/node-http-signature/pulls/67/comments","review_comment_url":"https://api.github.com/repos/joyent/node-http-signature/pulls/comments{/number}","comments_url":"https://api.github.com/repos/joyent/node-http-signature/issues/67/comments","statuses_url":"https://api.github.com/repos/joyent/node-http-signature/statuses/d4dbd7093bdc502ce2f92920e9bc470f8bd723b8","head":{"label":"ChALkeR:patch-1","ref":"patch-1","sha":"d4dbd7093bdc502ce2f92920e9bc470f8bd723b8","user":{"login":"ChALkeR","id":291301,"node_id":"MDQ6VXNlcjI5MTMwMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/291301?v=4","gravatar_id":"","url":"https://api.github.com/users/ChALkeR","html_url":"https://github.com/ChALkeR","followers_url":"https://api.github.com/users/ChALkeR/followers","following_url":"https://api.github.com/users/ChALkeR/following{/other_user}","gists_url":"https://api.github.com/users/ChALkeR/gists{/gist_id}","starred_url":"https://api.github.com/users/ChALkeR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChALkeR/subscriptions","organizations_url":"https://api.github.com/users/ChALkeR/orgs","repos_url":"https://api.github.com/users/ChALkeR/repos","events_url":"https://api.github.com/users/ChALkeR/events{/privacy}","received_events_url":"https://api.github.com/users/ChALkeR/received_events","type":"User","site_admin":false},"repo":{"id":123620834,"node_id":"MDEwOlJlcG9zaXRvcnkxMjM2MjA4MzQ=","name":"node-http-signature","full_name":"ChALkeR/node-http-signature","owner":{"login":"ChALkeR","id":291301,"node_id":"MDQ6VXNlcjI5MTMwMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/291301?v=4","gravatar_id":"","url":"https://api.github.com/users/ChALkeR","html_url":"https://github.com/ChALkeR","followers_url":"https://api.github.com/users/ChALkeR/followers","following_url":"https://api.github.com/users/ChALkeR/following{/other_user}","gists_url":"https://api.github.com/users/ChALkeR/gists{/gist_id}","starred_url":"https://api.github.com/users/ChALkeR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChALkeR/subscriptions","organizations_url":"https://api.github.com/users/ChALkeR/orgs","repos_url":"https://api.github.com/users/ChALkeR/repos","events_url":"https://api.github.com/users/ChALkeR/events{/privacy}","received_events_url":"https://api.github.com/users/ChALkeR/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ChALkeR/node-http-signature","description":"Reference implementation of Joyent's HTTP Signature Scheme","fork":true,"url":"https://api.github.com/repos/ChALkeR/node-http-signature","forks_url":"https://api.github.com/repos/ChALkeR/node-http-signature/forks","keys_url":"https://api.github.com/repos/ChALkeR/node-http-signature/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ChALkeR/node-http-signature/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ChALkeR/node-http-signature/teams","hooks_url":"https://api.github.com/repos/ChALkeR/node-http-signature/hooks","issue_events_url":"https://api.github.com/repos/ChALkeR/node-http-signature/issues/events{/number}","events_url":"https://api.github.com/repos/ChALkeR/node-http-signature/events","assignees_url":"https://api.github.com/repos/ChALkeR/node-http-signature/assignees{/user}","branches_url":"https://api.github.com/repos/ChALkeR/node-http-signature/branches{/branch}","tags_url":"https://api.github.com/repos/ChALkeR/node-http-signature/tags","blobs_url":"https://api.github.com/repos/ChALkeR/node-http-signature/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ChALkeR/node-http-signature/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ChALkeR/node-http-signature/git/refs{/sha}","trees_url":"https://api.github.com/repos/ChALkeR/node-http-signature/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ChALkeR/node-http-signature/statuses/{sha}","languages_url":"https://api.github.com/repos/ChALkeR/node-http-signature/languages","stargazers_url":"https://api.github.com/repos/ChALkeR/node-http-signature/stargazers","contributors_url":"https://api.github.com/repos/ChALkeR/node-http-signature/contributors","subscribers_url":"https://api.github.com/repos/ChALkeR/node-http-signature/subscribers","subscription_url":"https://api.github.com/repos/ChALkeR/node-http-signature/subscription","commits_url":"https://api.github.com/repos/ChALkeR/node-http-signature/commits{/sha}","git_commits_url":"https://api.github.com/repos/ChALkeR/node-http-signature/git/commits{/sha}","comments_url":"https://api.github.com/repos/ChALkeR/node-http-signature/comments{/number}","issue_comment_url":"https://api.github.com/repos/ChALkeR/node-http-signature/issues/comments{/number}","contents_url":"https://api.github.com/repos/ChALkeR/node-http-signature/contents/{+path}","compare_url":"https://api.github.com/repos/ChALkeR/node-http-signature/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ChALkeR/node-http-signature/merges","archive_url":"https://api.github.com/repos/ChALkeR/node-http-signature/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ChALkeR/node-http-signature/downloads","issues_url":"https://api.github.com/repos/ChALkeR/node-http-signature/issues{/number}","pulls_url":"https://api.github.com/repos/ChALkeR/node-http-signature/pulls{/number}","milestones_url":"https://api.github.com/repos/ChALkeR/node-http-signature/milestones{/number}","notifications_url":"https://api.github.com/repos/ChALkeR/node-http-signature/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ChALkeR/node-http-signature/labels{/name}","releases_url":"https://api.github.com/repos/ChALkeR/node-http-signature/releases{/id}","deployments_url":"https://api.github.com/repos/ChALkeR/node-http-signature/deployments","created_at":"2018-03-02T19:20:59Z","updated_at":"2018-03-02T19:21:00Z","pushed_at":"2018-03-02T19:37:09Z","git_url":"git://github.com/ChALkeR/node-http-signature.git","ssh_url":"git@github.com:ChALkeR/node-http-signature.git","clone_url":"https://github.com/ChALkeR/node-http-signature.git","svn_url":"https://github.com/ChALkeR/node-http-signature","homepage":"http://www.joyent.com","size":153,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"joyent:master","ref":"master","sha":"523e7c5a3a081e046813f62ab182e294a08eaf0d","user":{"login":"joyent","id":10161,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMTYx","avatar_url":"https://avatars0.githubusercontent.com/u/10161?v=4","gravatar_id":"","url":"https://api.github.com/users/joyent","html_url":"https://github.com/joyent","followers_url":"https://api.github.com/users/joyent/followers","following_url":"https://api.github.com/users/joyent/following{/other_user}","gists_url":"https://api.github.com/users/joyent/gists{/gist_id}","starred_url":"https://api.github.com/users/joyent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyent/subscriptions","organizations_url":"https://api.github.com/users/joyent/orgs","repos_url":"https://api.github.com/users/joyent/repos","events_url":"https://api.github.com/users/joyent/events{/privacy}","received_events_url":"https://api.github.com/users/joyent/received_events","type":"Organization","site_admin":false},"repo":{"id":2048781,"node_id":"MDEwOlJlcG9zaXRvcnkyMDQ4Nzgx","name":"node-http-signature","full_name":"joyent/node-http-signature","owner":{"login":"joyent","id":10161,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMTYx","avatar_url":"https://avatars0.githubusercontent.com/u/10161?v=4","gravatar_id":"","url":"https://api.github.com/users/joyent","html_url":"https://github.com/joyent","followers_url":"https://api.github.com/users/joyent/followers","following_url":"https://api.github.com/users/joyent/following{/other_user}","gists_url":"https://api.github.com/users/joyent/gists{/gist_id}","starred_url":"https://api.github.com/users/joyent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyent/subscriptions","organizations_url":"https://api.github.com/users/joyent/orgs","repos_url":"https://api.github.com/users/joyent/repos","events_url":"https://api.github.com/users/joyent/events{/privacy}","received_events_url":"https://api.github.com/users/joyent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/joyent/node-http-signature","description":"Reference implementation of Joyent's HTTP Signature Scheme","fork":false,"url":"https://api.github.com/repos/joyent/node-http-signature","forks_url":"https://api.github.com/repos/joyent/node-http-signature/forks","keys_url":"https://api.github.com/repos/joyent/node-http-signature/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joyent/node-http-signature/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joyent/node-http-signature/teams","hooks_url":"https://api.github.com/repos/joyent/node-http-signature/hooks","issue_events_url":"https://api.github.com/repos/joyent/node-http-signature/issues/events{/number}","events_url":"https://api.github.com/repos/joyent/node-http-signature/events","assignees_url":"https://api.github.com/repos/joyent/node-http-signature/assignees{/user}","branches_url":"https://api.github.com/repos/joyent/node-http-signature/branches{/branch}","tags_url":"https://api.github.com/repos/joyent/node-http-signature/tags","blobs_url":"https://api.github.com/repos/joyent/node-http-signature/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joyent/node-http-signature/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joyent/node-http-signature/git/refs{/sha}","trees_url":"https://api.github.com/repos/joyent/node-http-signature/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joyent/node-http-signature/statuses/{sha}","languages_url":"https://api.github.com/repos/joyent/node-http-signature/languages","stargazers_url":"https://api.github.com/repos/joyent/node-http-signature/stargazers","contributors_url":"https://api.github.com/repos/joyent/node-http-signature/contributors","subscribers_url":"https://api.github.com/repos/joyent/node-http-signature/subscribers","subscription_url":"https://api.github.com/repos/joyent/node-http-signature/subscription","commits_url":"https://api.github.com/repos/joyent/node-http-signature/commits{/sha}","git_commits_url":"https://api.github.com/repos/joyent/node-http-signature/git/commits{/sha}","comments_url":"https://api.github.com/repos/joyent/node-http-signature/comments{/number}","issue_comment_url":"https://api.github.com/repos/joyent/node-http-signature/issues/comments{/number}","contents_url":"https://api.github.com/repos/joyent/node-http-signature/contents/{+path}","compare_url":"https://api.github.com/repos/joyent/node-http-signature/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joyent/node-http-signature/merges","archive_url":"https://api.github.com/repos/joyent/node-http-signature/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joyent/node-http-signature/downloads","issues_url":"https://api.github.com/repos/joyent/node-http-signature/issues{/number}","pulls_url":"https://api.github.com/repos/joyent/node-http-signature/pulls{/number}","milestones_url":"https://api.github.com/repos/joyent/node-http-signature/milestones{/number}","notifications_url":"https://api.github.com/repos/joyent/node-http-signature/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joyent/node-http-signature/labels{/name}","releases_url":"https://api.github.com/repos/joyent/node-http-signature/releases{/id}","deployments_url":"https://api.github.com/repos/joyent/node-http-signature/deployments","created_at":"2011-07-14T17:58:00Z","updated_at":"2018-08-02T04:44:39Z","pushed_at":"2018-06-10T07:35:13Z","git_url":"git://github.com/joyent/node-http-signature.git","ssh_url":"git@github.com:joyent/node-http-signature.git","clone_url":"https://github.com/joyent/node-http-signature.git","svn_url":"https://github.com/joyent/node-http-signature","homepage":"http://www.joyent.com","size":156,"stargazers_count":324,"watchers_count":324,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":78,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":78,"open_issues":15,"watchers":324,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/joyent/node-http-signature/pulls/67"},"html":{"href":"https://github.com/joyent/node-http-signature/pull/67"},"issue":{"href":"https://api.github.com/repos/joyent/node-http-signature/issues/67"},"comments":{"href":"https://api.github.com/repos/joyent/node-http-signature/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/joyent/node-http-signature/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/joyent/node-http-signature/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/joyent/node-http-signature/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/joyent/node-http-signature/statuses/d4dbd7093bdc502ce2f92920e9bc470f8bd723b8"}},"author_association":"NONE"}}
{"actor":{"display_login":"jacobq"}}