{"action":"created","comment":{"url":"https://api.github.com/repos/michielbdejong/ludbud/pulls/comments/26384002","id":26384002,"diff_hunk":"@@ -56,29 +56,29 @@ ret.oauth = function(platform, userAddress, scopes) {\n     goTo('https://www.dropbox.com/1/oauth2/authorize');\n   } else if (platform === 'googledrive') {\n     goTo('https://accounts.google.com/o/oauth2/auth');\n-  } else if (platform === 'remotestorage' || platform === 'remotestorage-no-https') {\n-    var parts = userAddress.split('@');\n-    var prefix = 'https://';\n-    if (platform === 'remotestorage-no-https') {\n-      prefix = 'http://';\n-    }\n-    requestJSON(prefix + parts[1] + '/.well-known/webfinger?resource='+encodeURIComponent('acct:'+userAddress),\n-        undefined, function(err, data) {\n+  } else if (platform === 'remotestorage' || platform === 'remotestorage-allow-insecure-webfinger') {\n+\n+    var webfinger = new WebFinger({\n+      tls_only: (platform === 'remotestorage' ? true : false)\n+    });\n+    webfinger.lookup(userAddress, function (err, p) {\n       if (err) {\n         fail('error retrieving webfinger for '+userAddress, err);\n-      } else if (typeof data === 'object' && Array.isArray(data.links)) {\n-        for (var i=0; i< data.links.length; i++) {\n-          if (typeof data.links[i] === 'object'\n-              && data.links[i].rel === 'remotestorage'\n-              && typeof data.links[i].properties === 'object'\n-              && typeof data.links[i].properties['http://tools.ietf.org/html/rfc6749#section-4.2'] === 'string') {\n-            apiBaseURL = data.links[i].href;\n-            goTo(data.links[i].properties['http://tools.ietf.org/html/rfc6749#section-4.2']);\n+      } else if ((typeof p.idx === 'object')\n+          && (typeof p.idx.links == 'object')\n+          && (Array.isArray(p.idx.links.remotestorage))) {\n+        for (var i=0; i< p.idx.links.remotestorage.length; i++) {\n+          if ((typeof p.idx.links.remotestorage[i] === 'object')\n+              && typeof p.idx.links.remotestorage[i].href === 'string'\n+              && typeof p.idx.links.remotestorage[i].properties === 'object'\n+              && typeof p.idx.links.remotestorage[i].properties['http://tools.ietf.org/html/rfc6749#section-4.2'] === 'string') {","path":"src/oauth.js","position":44,"original_position":44,"commit_id":"1b37e21f6dfd0da3532a55bfc632ba8b57a045fe","original_commit_id":"1b37e21f6dfd0da3532a55bfc632ba8b57a045fe","user":{"login":"silverbucket","id":317571,"avatar_url":"https://avatars.githubusercontent.com/u/317571?v=3","gravatar_id":"","url":"https://api.github.com/users/silverbucket","html_url":"https://github.com/silverbucket","followers_url":"https://api.github.com/users/silverbucket/followers","following_url":"https://api.github.com/users/silverbucket/following{/other_user}","gists_url":"https://api.github.com/users/silverbucket/gists{/gist_id}","starred_url":"https://api.github.com/users/silverbucket/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silverbucket/subscriptions","organizations_url":"https://api.github.com/users/silverbucket/orgs","repos_url":"https://api.github.com/users/silverbucket/repos","events_url":"https://api.github.com/users/silverbucket/events{/privacy}","received_events_url":"https://api.github.com/users/silverbucket/received_events","type":"User","site_admin":false},"body":"See here for a much simpler example:\r\nhttps://github.com/remotestorage/remotestorage.js/blob/master/src/discover.js#L56-L60\r\n\r\nNote that above this, there's a check for whether the remotestorage is an array or not. This is actually an unneeded check, since it'll always be an array you'd only care of the array is zero-length, then there's no remotestorage record.","created_at":"2015-03-13T13:14:34Z","updated_at":"2015-03-13T13:14:34Z","html_url":"https://github.com/michielbdejong/ludbud/pull/8#discussion_r26384002","pull_request_url":"https://api.github.com/repos/michielbdejong/ludbud/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/michielbdejong/ludbud/pulls/comments/26384002"},"html":{"href":"https://github.com/michielbdejong/ludbud/pull/8#discussion_r26384002"},"pull_request":{"href":"https://api.github.com/repos/michielbdejong/ludbud/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/michielbdejong/ludbud/pulls/8","id":31123085,"html_url":"https://github.com/michielbdejong/ludbud/pull/8","diff_url":"https://github.com/michielbdejong/ludbud/pull/8.diff","patch_url":"https://github.com/michielbdejong/ludbud/pull/8.patch","issue_url":"https://api.github.com/repos/michielbdejong/ludbud/issues/8","number":8,"state":"open","locked":false,"title":"switch to webfinger.js","user":{"login":"michielbdejong","id":408412,"avatar_url":"https://avatars.githubusercontent.com/u/408412?v=3","gravatar_id":"","url":"https://api.github.com/users/michielbdejong","html_url":"https://github.com/michielbdejong","followers_url":"https://api.github.com/users/michielbdejong/followers","following_url":"https://api.github.com/users/michielbdejong/following{/other_user}","gists_url":"https://api.github.com/users/michielbdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/michielbdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michielbdejong/subscriptions","organizations_url":"https://api.github.com/users/michielbdejong/orgs","repos_url":"https://api.github.com/users/michielbdejong/repos","events_url":"https://api.github.com/users/michielbdejong/events{/privacy}","received_events_url":"https://api.github.com/users/michielbdejong/received_events","type":"User","site_admin":false},"body":"I got it working, but I'm not sure whether src/oauth.js has actually become in any way simpler by using this...","created_at":"2015-03-13T12:53:36Z","updated_at":"2015-03-13T13:14:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"deb7b48560e6d92d0ce051bed0392352ebb1ab8d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/michielbdejong/ludbud/pulls/8/commits","review_comments_url":"https://api.github.com/repos/michielbdejong/ludbud/pulls/8/comments","review_comment_url":"https://api.github.com/repos/michielbdejong/ludbud/pulls/comments{/number}","comments_url":"https://api.github.com/repos/michielbdejong/ludbud/issues/8/comments","statuses_url":"https://api.github.com/repos/michielbdejong/ludbud/statuses/1b37e21f6dfd0da3532a55bfc632ba8b57a045fe","head":{"label":"michielbdejong:webfinger.js","ref":"webfinger.js","sha":"1b37e21f6dfd0da3532a55bfc632ba8b57a045fe","user":{"login":"michielbdejong","id":408412,"avatar_url":"https://avatars.githubusercontent.com/u/408412?v=3","gravatar_id":"","url":"https://api.github.com/users/michielbdejong","html_url":"https://github.com/michielbdejong","followers_url":"https://api.github.com/users/michielbdejong/followers","following_url":"https://api.github.com/users/michielbdejong/following{/other_user}","gists_url":"https://api.github.com/users/michielbdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/michielbdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michielbdejong/subscriptions","organizations_url":"https://api.github.com/users/michielbdejong/orgs","repos_url":"https://api.github.com/users/michielbdejong/repos","events_url":"https://api.github.com/users/michielbdejong/events{/privacy}","received_events_url":"https://api.github.com/users/michielbdejong/received_events","type":"User","site_admin":false},"repo":{"id":31421094,"name":"ludbud","full_name":"michielbdejong/ludbud","owner":{"login":"michielbdejong","id":408412,"avatar_url":"https://avatars.githubusercontent.com/u/408412?v=3","gravatar_id":"","url":"https://api.github.com/users/michielbdejong","html_url":"https://github.com/michielbdejong","followers_url":"https://api.github.com/users/michielbdejong/followers","following_url":"https://api.github.com/users/michielbdejong/following{/other_user}","gists_url":"https://api.github.com/users/michielbdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/michielbdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michielbdejong/subscriptions","organizations_url":"https://api.github.com/users/michielbdejong/orgs","repos_url":"https://api.github.com/users/michielbdejong/repos","events_url":"https://api.github.com/users/michielbdejong/events{/privacy}","received_events_url":"https://api.github.com/users/michielbdejong/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/michielbdejong/ludbud","description":"Let user data be user data","fork":false,"url":"https://api.github.com/repos/michielbdejong/ludbud","forks_url":"https://api.github.com/repos/michielbdejong/ludbud/forks","keys_url":"https://api.github.com/repos/michielbdejong/ludbud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michielbdejong/ludbud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michielbdejong/ludbud/teams","hooks_url":"https://api.github.com/repos/michielbdejong/ludbud/hooks","issue_events_url":"https://api.github.com/repos/michielbdejong/ludbud/issues/events{/number}","events_url":"https://api.github.com/repos/michielbdejong/ludbud/events","assignees_url":"https://api.github.com/repos/michielbdejong/ludbud/assignees{/user}","branches_url":"https://api.github.com/repos/michielbdejong/ludbud/branches{/branch}","tags_url":"https://api.github.com/repos/michielbdejong/ludbud/tags","blobs_url":"https://api.github.com/repos/michielbdejong/ludbud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michielbdejong/ludbud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michielbdejong/ludbud/git/refs{/sha}","trees_url":"https://api.github.com/repos/michielbdejong/ludbud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michielbdejong/ludbud/statuses/{sha}","languages_url":"https://api.github.com/repos/michielbdejong/ludbud/languages","stargazers_url":"https://api.github.com/repos/michielbdejong/ludbud/stargazers","contributors_url":"https://api.github.com/repos/michielbdejong/ludbud/contributors","subscribers_url":"https://api.github.com/repos/michielbdejong/ludbud/subscribers","subscription_url":"https://api.github.com/repos/michielbdejong/ludbud/subscription","commits_url":"https://api.github.com/repos/michielbdejong/ludbud/commits{/sha}","git_commits_url":"https://api.github.com/repos/michielbdejong/ludbud/git/commits{/sha}","comments_url":"https://api.github.com/repos/michielbdejong/ludbud/comments{/number}","issue_comment_url":"https://api.github.com/repos/michielbdejong/ludbud/issues/comments{/number}","contents_url":"https://api.github.com/repos/michielbdejong/ludbud/contents/{+path}","compare_url":"https://api.github.com/repos/michielbdejong/ludbud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michielbdejong/ludbud/merges","archive_url":"https://api.github.com/repos/michielbdejong/ludbud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michielbdejong/ludbud/downloads","issues_url":"https://api.github.com/repos/michielbdejong/ludbud/issues{/number}","pulls_url":"https://api.github.com/repos/michielbdejong/ludbud/pulls{/number}","milestones_url":"https://api.github.com/repos/michielbdejong/ludbud/milestones{/number}","notifications_url":"https://api.github.com/repos/michielbdejong/ludbud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michielbdejong/ludbud/labels{/name}","releases_url":"https://api.github.com/repos/michielbdejong/ludbud/releases{/id}","created_at":"2015-02-27T13:47:00Z","updated_at":"2015-03-12T20:04:23Z","pushed_at":"2015-03-13T12:52:01Z","git_url":"git://github.com/michielbdejong/ludbud.git","ssh_url":"git@github.com:michielbdejong/ludbud.git","clone_url":"https://github.com/michielbdejong/ludbud.git","svn_url":"https://github.com/michielbdejong/ludbud","homepage":null,"size":500,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":6,"default_branch":"master"}},"base":{"label":"michielbdejong:master","ref":"master","sha":"5d2faf42a702ad6133bd4313128b5291ce56308a","user":{"login":"michielbdejong","id":408412,"avatar_url":"https://avatars.githubusercontent.com/u/408412?v=3","gravatar_id":"","url":"https://api.github.com/users/michielbdejong","html_url":"https://github.com/michielbdejong","followers_url":"https://api.github.com/users/michielbdejong/followers","following_url":"https://api.github.com/users/michielbdejong/following{/other_user}","gists_url":"https://api.github.com/users/michielbdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/michielbdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michielbdejong/subscriptions","organizations_url":"https://api.github.com/users/michielbdejong/orgs","repos_url":"https://api.github.com/users/michielbdejong/repos","events_url":"https://api.github.com/users/michielbdejong/events{/privacy}","received_events_url":"https://api.github.com/users/michielbdejong/received_events","type":"User","site_admin":false},"repo":{"id":31421094,"name":"ludbud","full_name":"michielbdejong/ludbud","owner":{"login":"michielbdejong","id":408412,"avatar_url":"https://avatars.githubusercontent.com/u/408412?v=3","gravatar_id":"","url":"https://api.github.com/users/michielbdejong","html_url":"https://github.com/michielbdejong","followers_url":"https://api.github.com/users/michielbdejong/followers","following_url":"https://api.github.com/users/michielbdejong/following{/other_user}","gists_url":"https://api.github.com/users/michielbdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/michielbdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michielbdejong/subscriptions","organizations_url":"https://api.github.com/users/michielbdejong/orgs","repos_url":"https://api.github.com/users/michielbdejong/repos","events_url":"https://api.github.com/users/michielbdejong/events{/privacy}","received_events_url":"https://api.github.com/users/michielbdejong/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/michielbdejong/ludbud","description":"Let user data be user data","fork":false,"url":"https://api.github.com/repos/michielbdejong/ludbud","forks_url":"https://api.github.com/repos/michielbdejong/ludbud/forks","keys_url":"https://api.github.com/repos/michielbdejong/ludbud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/michielbdejong/ludbud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/michielbdejong/ludbud/teams","hooks_url":"https://api.github.com/repos/michielbdejong/ludbud/hooks","issue_events_url":"https://api.github.com/repos/michielbdejong/ludbud/issues/events{/number}","events_url":"https://api.github.com/repos/michielbdejong/ludbud/events","assignees_url":"https://api.github.com/repos/michielbdejong/ludbud/assignees{/user}","branches_url":"https://api.github.com/repos/michielbdejong/ludbud/branches{/branch}","tags_url":"https://api.github.com/repos/michielbdejong/ludbud/tags","blobs_url":"https://api.github.com/repos/michielbdejong/ludbud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/michielbdejong/ludbud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/michielbdejong/ludbud/git/refs{/sha}","trees_url":"https://api.github.com/repos/michielbdejong/ludbud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/michielbdejong/ludbud/statuses/{sha}","languages_url":"https://api.github.com/repos/michielbdejong/ludbud/languages","stargazers_url":"https://api.github.com/repos/michielbdejong/ludbud/stargazers","contributors_url":"https://api.github.com/repos/michielbdejong/ludbud/contributors","subscribers_url":"https://api.github.com/repos/michielbdejong/ludbud/subscribers","subscription_url":"https://api.github.com/repos/michielbdejong/ludbud/subscription","commits_url":"https://api.github.com/repos/michielbdejong/ludbud/commits{/sha}","git_commits_url":"https://api.github.com/repos/michielbdejong/ludbud/git/commits{/sha}","comments_url":"https://api.github.com/repos/michielbdejong/ludbud/comments{/number}","issue_comment_url":"https://api.github.com/repos/michielbdejong/ludbud/issues/comments{/number}","contents_url":"https://api.github.com/repos/michielbdejong/ludbud/contents/{+path}","compare_url":"https://api.github.com/repos/michielbdejong/ludbud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/michielbdejong/ludbud/merges","archive_url":"https://api.github.com/repos/michielbdejong/ludbud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/michielbdejong/ludbud/downloads","issues_url":"https://api.github.com/repos/michielbdejong/ludbud/issues{/number}","pulls_url":"https://api.github.com/repos/michielbdejong/ludbud/pulls{/number}","milestones_url":"https://api.github.com/repos/michielbdejong/ludbud/milestones{/number}","notifications_url":"https://api.github.com/repos/michielbdejong/ludbud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/michielbdejong/ludbud/labels{/name}","releases_url":"https://api.github.com/repos/michielbdejong/ludbud/releases{/id}","created_at":"2015-02-27T13:47:00Z","updated_at":"2015-03-12T20:04:23Z","pushed_at":"2015-03-13T12:52:01Z","git_url":"git://github.com/michielbdejong/ludbud.git","ssh_url":"git@github.com:michielbdejong/ludbud.git","clone_url":"https://github.com/michielbdejong/ludbud.git","svn_url":"https://github.com/michielbdejong/ludbud","homepage":null,"size":500,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/michielbdejong/ludbud/pulls/8"},"html":{"href":"https://github.com/michielbdejong/ludbud/pull/8"},"issue":{"href":"https://api.github.com/repos/michielbdejong/ludbud/issues/8"},"comments":{"href":"https://api.github.com/repos/michielbdejong/ludbud/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/michielbdejong/ludbud/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/michielbdejong/ludbud/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/michielbdejong/ludbud/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/michielbdejong/ludbud/statuses/1b37e21f6dfd0da3532a55bfc632ba8b57a045fe"}}}}