Skip to content
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

Getting "Error: gundb failed to authenticate user: Unverified data." when trying to create a folder in UserStorage #72

Open
talentlessguy opened this issue Apr 25, 2021 · 8 comments

Comments

@talentlessguy
Copy link

talentlessguy commented Apr 25, 2021

code:

import { Users, UserStorage } from '@spacehq/sdk'

const users = new Users({ endpoint: 'wss://auth-dev.space.storage' })

const identity = await users.createIdentity()

const user = await users.authenticate(identity)

const storage = new UserStorage(user)

await storage.createFolder({ bucket: 'bucket', path: 'pkg' })

error:

/home/v1rtl/Coding/x/node_modules/.pnpm/@[email protected]/node_modules/@spacehq/storage/dist/metadata/gundbMetadataStore.js:501
                            reject(new Error(`gundb failed to authenticate user: ${auth.err}`));
                                   ^

Error: gundb failed to authenticate user: Unverified data.
    at Object.ack (/home/v1rtl/Coding/xnode_modules/.pnpm/@[email protected]/node_modules/@spacehq/storage/src/metadata/gundbMetadataStore.ts:579:20)

info:

  • @spacehq/sdk: 0.0.30
  • Node v16
@jsonsivar
Copy link
Member

Hi @talentlessguy , could you try this without the endpoint: 'wss://auth-dev.space.storage' and let us know how that goes? The value you currently have is a development sandbox and the problem with using that is there are other environment variables that are defaulted to match auth.space.storage which is the default so just overriding the endpoint would have a mismatch between that and the other env vars. This was because the dev sandbox was originally intended for internal use.

What we can maybe do is add a config flag called e.g., devMode: true that overrides all the variables to use the dev one so you can test in a non-prod setting. Will take this down as a feature request for now.

Another thing to note in your snippet is that before creating the folder, you would need to create a bucket called bucket first. This is because the initialization creates a default bucket called personal. So you can use that for subsequent operations or create a custom bucket if you want another bucket.

@talentlessguy
Copy link
Author

talentlessguy commented Apr 26, 2021

@jsonsivar thanks for responding!

I've tried to switch to this:

import { Users, UserStorage } from '@spacehq/sdk'

const users = new Users({ endpoint: 'wss://auth.space.storage' })

async function run() {
  const identity = await users.createIdentity()

  const user = await users.authenticate(identity)

  const storage = new UserStorage(user)

  await storage.createFolder({ bucket: 'bucket', path: 'pkg' })

  console.log(await storage.listDirectory({ bucket: 'bucket', path: '.' }))
}

run()

it returns a new error:

reject(new Error(`gundb failed to authenticate user: ${auth.err}`));
                                   ^

Error: gundb failed to authenticate user: Unverified data.
    at Object.ack (/home/v1rtl/Coding/x/node_modules/.pnpm/@[email protected]/node_modules/@spacehq/storage/src/metadata/gundbMetadataStore.ts:579:20)

I've got a few questions:

  • Where do I get the API key from?
  • Where should I pass it?
  • How do I create a bucket in space.storage?

@jsonsivar
Copy link
Member

jsonsivar commented Apr 30, 2021

Hi @talentlessguy , I wasn't able to replicate this in my node environment. I realized you are on Node 16 so I will try upgrading to that and see if I can replicate it. In the meantime re: your other questions:

Where do I get the API key from?

You shouldn't need any API keys for this.

How do I create a bucket in space.storage?

The default bucket called personal is created so you can use that for now. We still need to expose the functionality to create arbitrary buckets.

@jsonsivar
Copy link
Member

@talentlessguy. I was able to reproduce this. The confusion was that our integration tests actually simulate the browser environment and so the SDK has only been tested and supported in a browser environment. I think there is an underlying issue with using Gun directly in NodeJS when using the SEA authenticated as we are. Found this but is a bit outdated amark/gun#579. We will need to dig further and see if there is an issue with the library or if it's our code and will keep you posted.

@talentlessguy
Copy link
Author

@jsonsivar thanks for investigation! Glad that you figured out the root of the problem

by the way, I recommend to add integration tests for Nodejs as well because SDK should be usable with Node.js

@harrisonhines
Copy link

Thats a great idea. We will try to add that in the next few weeks.

@talentlessguy
Copy link
Author

talentlessguy commented May 6, 2021

hey, gun just had an update that is up to date with master branch (0.2020.1232)

this means all bugfixes (including amark/gun#579) are now in gun

could you please update to latest and run it through integration tests?

thanks in advance

@amark
Copy link

amark commented May 6, 2021

Hmm, that was closed in 2018, I don't think it is the issue. 2020 had some regressions when browser/nodejs are not using same version, so try to match same version as the peers you are connecting to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants