oddsdk / ts-odd

An SDK for building apps with decentralized identity and storage.
https://odd.dev/
Apache License 2.0
178 stars 24 forks source link

fs.cat permission error on public files #399

Closed gotjoshua closed 2 years ago

gotjoshua commented 2 years ago

Summary with details

I have a file clearly available in a public user folder Screen Shot 2022-08-06 at 11 55 08 AM

When i try to access it via cat i get this error:

Uncaught (in promise) NoPermissionError: 
I don't have the necessary permissions to query the file system at 
"public,1zm-test1,color-schemes-test1,
links,1zoom_Colors,
1659714480000_16:48:00.000,1659714481311_4f80923d0fe_b9705a4ee1f"

note1: [links,1zoom_Colors,] is a wnfs symlink to: https://1zoom.files.fission.name/p/1zm-test1/color-schemes-test1/Colors/

note2: I can ls the folder just fine (thats how i get the filename to try the cat command

Desktop (please complete the following information):

icidasset commented 2 years ago

What does your permissions object look like that you pass to initialise?

gotjoshua commented 2 years ago

What does your permissions object look like

const suffix = '-test3'
export const appNameObj = {
  name: `color-schemes${suffix}`,
  creator: `1zm${suffix}`,
}

  const publicDirectoryArray = [
    wn.path.directory(appNameObj.creator, appNameObj.name), 
    wn.path.directory(appNameObj.creator, appNameObj.name, 'links')
  ]

  state = await wn.initialise({ 
    permissions: {
      app: appNameObj,
      fs: { // Ask the user permission for additional filesystem paths
        public: publicDirectoryArray,
      },
    },
  })

not sure if it makes much sense to continue this line of inquiry until after your big upgrade is released...

but... I think the permissions object should be completely irrelevant if i am querying a public path ls and exists and cat should all be easy to use for all users public paths, independent of any permissions.

icidasset commented 2 years ago

We chose this route so the user can easily see when authorising an app which files an app will touch. But yes, you're right, for reading we might need to change that, since it's public anyway.

Does this work when you request permissions for the entire public directory?

icidasset commented 2 years ago

Which you would do in the following way:

permissions: {
  fs: {
    public: [ wn.path.root() ]
  }
}
gotjoshua commented 2 years ago

Does this work when you request permissions for the entire public directory?

I'll need to check later... neck deep in other stuff and no longer interested in using cat with single files as the car file strategy for the whole directory is sooooo much faster.

(but thanks for engaging, none the less!)