-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
switch to webfinger.js #8
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/bash | ||
cat src/pre.js src/request.js src/instance.js src/oauth.js src/post.js > ludbud.js | ||
cat lib/webfinger.min.js src/pre.js src/request.js src/instance.js src/oauth.js src/post.js > ludbud.js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ function getClientId(platform) { | |
} | ||
} | ||
ret.oauth = function(platform, userAddress, scopes) { | ||
if (platform !== 'remotestorage') { | ||
if (platform !== 'remotestorage' && platform !== 'remotestorage-allow-insecure-webfinger') { | ||
fail('WARNING: platform ' + platform + ' not fully supported yet'); | ||
} | ||
var apiBaseURL; | ||
|
@@ -56,29 +56,21 @@ ret.oauth = function(platform, userAddress, scopes) { | |
goTo('https://www.dropbox.com/1/oauth2/authorize'); | ||
} else if (platform === 'googledrive') { | ||
goTo('https://accounts.google.com/o/oauth2/auth'); | ||
} else if (platform === 'remotestorage' || platform === 'remotestorage-no-https') { | ||
var parts = userAddress.split('@'); | ||
var prefix = 'https://'; | ||
if (platform === 'remotestorage-no-https') { | ||
prefix = 'http://'; | ||
} | ||
requestJSON(prefix + parts[1] + '/.well-known/webfinger?resource='+encodeURIComponent('acct:'+userAddress), | ||
undefined, function(err, data) { | ||
} else if (platform === 'remotestorage' || platform === 'remotestorage-allow-insecure-webfinger') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one as well. |
||
|
||
var webfinger = new WebFinger({ | ||
tls_only: (platform === 'remotestorage' ? true : false) | ||
}); | ||
webfinger.lookupLink(userAddress, 'remotestorage', function (err, link) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These four lines are definitely good to get rid of. |
||
if (err) { | ||
fail('error retrieving webfinger for '+userAddress, err); | ||
} else if (typeof data === 'object' && Array.isArray(data.links)) { | ||
for (var i=0; i< data.links.length; i++) { | ||
if (typeof data.links[i] === 'object' | ||
&& data.links[i].rel === 'remotestorage' | ||
&& typeof data.links[i].properties === 'object' | ||
&& typeof data.links[i].properties['http://tools.ietf.org/html/rfc6749#section-4.2'] === 'string') { | ||
apiBaseURL = data.links[i].href; | ||
goTo(data.links[i].properties['http://tools.ietf.org/html/rfc6749#section-4.2']); | ||
return; | ||
} | ||
} | ||
fail('error discovering remoteStorage location for '+userAddress, err); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like how here you can see directly that |
||
} else if (typeof link.href === 'string' | ||
&& typeof link.properties === 'object' | ||
&& typeof link.properties['http://tools.ietf.org/html/rfc6749#section-4.2'] === 'string') { | ||
apiBaseURL = link.href; | ||
goTo(link.properties['http://tools.ietf.org/html/rfc6749#section-4.2']); | ||
} else { | ||
fail('error parsing webfinger for '+userAddress + JSON.stringify(data)); | ||
fail('error parsing remoteStorage link for '+userAddress + JSON.stringify(link)); | ||
} | ||
}); | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is actually unrelated, btw.