-
Notifications
You must be signed in to change notification settings - Fork 324
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
Feat: IpfsApiAccessError #458
Conversation
Looking for thoughts here. |
Browserify issue?While it seems to work in tests, real life version injected as content script does not seem to produce Error with additional attributes. Try executing this against some website (and deny access to trigger error): ipfs.files.add(Buffer.from('seed')).catch(e => console.log(`Error.permission=${e.permission}, scope=${e.scope}, message=${e.message}`)) I get: Are you able to reproduce? Namespace for proxy-specific stuffThe Perhaps a safer alternative is to use @olizilla @alanshaw do we have any strong opinions or preferred conventions for handling this? |
Yes, I posted my comments here #455 (comment) |
On the posix stuff, I did check this originally because it needs to be posix. The path module as included by browserify is https://github.com/substack/path-browserify/blob/master/index.js which seems to be using the posix versions and doesn't include a |
@JonKrone to limit the number of moving pieces, let's go with version proposed by @alanshaw in #455 (comment) (no new type, just a self-explanatory property): if (err.isIpfsProxyAclError) { That way we don't have to change anything on the backend and we don't need to think where to put the new type. |
0e800fe
to
3ad9eeb
Compare
Hey guys, I'm sorry for the delay! I was totally swamped last week. I pushed some changes a few days ago, thanks @alanshaw for the solution with ipfs-postmsg. re: the posix path fix for tests on Windows: I explicitly imported |
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.
Thanks! The key properties that address needs raised in #455 look goood 👌
Small details remain to be fixed before we merge it, see below.
@@ -1,4 +1,5 @@ | |||
const Path = require('path') | |||
// Use path-browserify for consistent behavior between browser and tests on Windows |
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.
I think explicitly using path-browserify
(which provides posix version by default) is bit safer than assuming browserify-ing process will swap the implementation.
Let's merge this, and if at some point path-browserify
turns out to be not enough, we can swap it with own implementation / wrapper.
@alanshaw does it sound ok to you?
docs/window.ipfs.md
Outdated
} catch (err) { | ||
if (err.isIpfsProxyAclError) { | ||
// Fallback | ||
console.log(':(') |
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.
I would replace console.log(':(')
with console.log('Unable to get ACL decision from user :(', err)
to make it more obvious for first-timers :)
…denies permission
Tests were not running because some path parser didn't understand apostrophes so I've just converted those to escaped quotes. Some pre-mfs-scope tests failed because path.join presumes we want paths for the current running OS. I changed it to always use posix paths but I'm open to arguments that changing the implementation is a better approach. All of our target environments use posix paths, I believe.
f3e8d9e
to
a840622
Compare
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.
Sorry it took so long to review this :)
Doc with err.isIpfsProxyAclError
looks good, let's merge this.
Use a common
Error
type,IpfsApiAccessError
, when an app is denied access to a window.ipfs api.Discussed in #455.
Remaining:
window.ipfs
. Perhaps theipfs.types
oripfs.utils
from Support and reuse ipfs.types and ipfs.util #444?
This also fixes some
path.sep
related test failures on Windows, lemme know what you think about that.