Easier Postmessage Origin handling & Popup Build Script#30
Conversation
ce3a4e9 to
99dab3c
Compare
99dab3c to
0fd6f74
Compare
0fd6f74 to
657569b
Compare
Additionally, add `solid-auth-client` CLI for generating the popup.
657569b to
aecd02e
Compare
|
@RubenVerborgh this is ready for review! |
| build a static popup bound to your application's name. | ||
|
|
||
| Keeping this in mind, here's how to get things working. | ||
| Keeping this in mind, it's pretty simple to build a popup for your app! |
There was a problem hiding this comment.
I suppose they could even just edit the HTML at this point, it has become so easy 😉
|
|
||
| // helpers | ||
|
|
||
| function ns(fn) { |
There was a problem hiding this comment.
Maybe a comment about what this does?
bin/solid-auth-client.js
Outdated
|
|
||
| function ns(fn) { | ||
| return function() { | ||
| fn.apply( |
There was a problem hiding this comment.
There's no need for apply anymore in ES6, just use the spread operator.
bin/solid-auth-client.js
Outdated
| 'dist-popup/popup.html' | ||
| ) | ||
| if (!fs.existsSync(templateFilename)) { | ||
| const issueUrl = 'https://github.com/solid/solid-auth-client/issues' |
There was a problem hiding this comment.
maybe hoist all the way up the file?
bin/solid-auth-client.js
Outdated
| } | ||
| } | ||
|
|
||
| const log = ns(console.log.bind(console)) |
There was a problem hiding this comment.
No need to bind; log works independently (in Node, not the browser).
popup-app/index.js
Outdated
| } | ||
|
|
||
| function getStoredAppOrigin() { | ||
| return getData(sessionStorage).then(data => data.appOrigin) |
There was a problem hiding this comment.
I'd just use async/await consistently.
src/ipc.js
Outdated
| if (origin !== clientOrigin) { | ||
| console.warn( | ||
| `SECURITY WARNING: solid-auth-client is listening for messages from ${childOrigin},` + | ||
| `SECURITY WARNING: solid-auth-client is listening for messages from ${clientOrigin},` + |
There was a problem hiding this comment.
I'd explicitly say that the message has been rejected.
src/popup.js
Outdated
|
|
||
| export const appOriginHandler = (req: request): ?Promise<response> => { | ||
| const { id, method } = req | ||
| switch (method) { |
There was a problem hiding this comment.
Could be a simple if I suppose.
bin/solid-auth-client.js
Outdated
|
|
||
| program | ||
| .version(version) | ||
| .command('generate-popup <trusted-name> [filename]') |
There was a problem hiding this comment.
Why is required? Also, I found the name confusing.
| @@ -1 +0,0 @@ | |||
| POPUP_URI=http://localhost:8081/popup.html | |||
There was a problem hiding this comment.
Some mentions of the .env files are left in the README.
This PR: