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

Question to shareViaPublicKey #75

Open
StephanGerbeth opened this issue Jun 6, 2021 · 1 comment
Open

Question to shareViaPublicKey #75

StephanGerbeth opened this issue Jun 6, 2021 · 1 comment

Comments

@StephanGerbeth
Copy link

Hi,

I would like to use your shareViaPublicKey API.

await storage.shareViaPublicKey({
    publicKeys: [{
      id: '[email protected]', // or any identifier for the user
      pk: 'user-pk-hex-or-multibase', // optional, omit if user doesn't exist yet, it would generate temp access key
    }],
    paths: [{
        bucket: 'personal',
        path: '/file/path/here'
    }],
});

However, I currently do not understand which value I should store behind the attribute 'id' or where I resolve this value.

publicKeys: [{
      id: '[email protected]', // or any identifier for the user
      pk: 'user-pk-hex-or-multibase', // optional, omit if user doesn't exist yet, it would generate temp access key
    }]

Can you explain this to me in more detail?
Currently i use a modified Version of the class BrowserStorage to Authenticate users on the local device by Webauthn.

Thanks in advance
Stephan

@StephanGerbeth
Copy link
Author

Update:

I have played around a bit with your API and looked at your tests more closely. I have now come up with the following solution:

To share files between two clients, both parties must have created a mailbox:

const mailbox = await userStorage.initMailboxForUser(user)

furthermore an authentication has to be done

const {sig} = mailbox.getUserAuth()

The response received contains a "sig" that must be exchanged between the clients. This sig of the other client can then be used in combination with its PublicKey to execute the following command:

userStorage.shareViaPublicKey({
    publicKeys: [{
        id: remoteSig,
        pk: remotePublicKey
      };
    }),
    paths: [{...}]
  });

The remote user will be notified as in the following:

const response = await userStorage.notificationSubscribe();
response.on('data', ({ notification }) => {
   userStorage.handleFileInvitation(notification.id, true);
});

With this procedure I was able to realize a complete share of a file between two clients.
Is this exactly how you want it to be handled or should it be handled differently?

Cheers
Stephan

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

No branches or pull requests

1 participant