-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix #324 * npm update * update npm outdated * fix lint * update npm outdated * Explicitly use fetch from s-a-c * npm install * npm install rdflib@latest pane-registry@latest solid-namespace@latest * npm install --save-dev solid-auth-cli * npm update * package-lock.json
- Loading branch information
1 parent
7c82693
commit af52d52
Showing
7 changed files
with
4,187 additions
and
3,192 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict' | ||
/** | ||
* Provides a simple configuration object for Solid web client and other | ||
* modules. | ||
* @module config-default | ||
*/ | ||
module.exports = { | ||
/** | ||
* Primary authentication endpoint | ||
*/ | ||
authEndpoint: '', | ||
|
||
/** | ||
* Fallback authentication endpoint | ||
*/ | ||
fallbackAuthEndpoint: 'https://databox.me/', | ||
|
||
/** | ||
* Default signup endpoints (list of identity providers) | ||
*/ | ||
signupEndpoint: 'https://solid.github.io/solid-idps/', | ||
|
||
/** | ||
* Default height of the Signup popup window, in pixels | ||
*/ | ||
signupWindowHeight: 600, | ||
|
||
/** | ||
* Default width of the Signup popup window, in pixels | ||
*/ | ||
signupWindowWidth: 1024, | ||
|
||
/** | ||
* Path to the client private key (only needed when running within node) | ||
*/ | ||
key: '', | ||
|
||
/** | ||
* Path to the client certificate (only needed when running within node) | ||
*/ | ||
cert: '' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
var defaultConfig = require('./config-default') | ||
|
||
/** | ||
* Provides functionality for signing up with a Solid provider | ||
* @module signup | ||
*/ | ||
|
||
/** | ||
* Creates a Signup UI manager | ||
* @class | ||
*/ | ||
function Signup (config) { | ||
this.config = config || defaultConfig | ||
} | ||
|
||
/** | ||
* Sets up an event listener to monitor login messages from child window/iframe | ||
* @method listen | ||
* @return {Promise<String>} Event listener promise, resolves to user's WebID | ||
*/ | ||
Signup.prototype.listen = function listen () { | ||
var promise = new Promise(function (resolve, reject) { | ||
var eventMethod = window.addEventListener | ||
? 'addEventListener' | ||
: 'attachEvent' | ||
var eventListener = window[eventMethod] | ||
var messageEvent = eventMethod === 'attachEvent' | ||
? 'onmessage' | ||
: 'message' | ||
eventListener(messageEvent, function (e) { | ||
var u = e.data | ||
if (u.slice(0, 5) === 'User:') { | ||
var user = u.slice(5, u.length) | ||
if (user && user.length > 0 && user.slice(0, 4) === 'http') { | ||
return resolve(user) | ||
} else { | ||
return reject(user) | ||
} | ||
} | ||
}, true) | ||
}) | ||
return promise | ||
} | ||
|
||
/** | ||
* Opens a signup popup window, sets up `listen()`. | ||
* @method signup | ||
* @static | ||
* @param signupUrl {String} Location of a Solid server for user signup. | ||
* @return {Promise<String>} Returns a listener promise, resolves with signed | ||
* up user's WebID. | ||
*/ | ||
Signup.prototype.signup = function signup (signupUrl) { | ||
signupUrl = signupUrl || this.config.signupEndpoint | ||
var width = this.config.signupWindowWidth | ||
var height = this.config.signupWindowHeight | ||
// set borders | ||
var leftPosition = (window.screen.width / 2) - ((width / 2) + 10) | ||
// set title and status bars | ||
var topPosition = (window.screen.height / 2) - ((height / 2) + 50) | ||
var windowTitle = 'Solid signup' | ||
var windowUrl = signupUrl + '?origin=' + | ||
encodeURIComponent(window.location.origin) | ||
var windowSpecs = 'resizable,scrollbars,status,width=' + width + ',height=' + | ||
height + ',left=' + leftPosition + ',top=' + topPosition | ||
window.open(windowUrl, windowTitle, windowSpecs) | ||
var self = this | ||
return new Promise(function (resolve) { | ||
self.listen() | ||
.then(function (webid) { | ||
return resolve(webid) | ||
}) | ||
}) | ||
} | ||
|
||
module.exports = Signup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters