On-sharing & Client Tasks
Share Terms
When sharing an item, a block of text can be added to the share, there is no required structure for these terms but something like the following should give you some idea of how it might be used.
I have allowed on-sharing on this item but before any on-sharing takes place call me on my phone to confirm it with me.
or
This information on this item is being shared for the express purpose of applying for a home loan, it is not to be shared with anyone for the purposes of marketing or analysis.
or
This information contains non-public business information and is for the eyes of Anthony Edward Stark only.
Share Acceptance
When creating a share there is an option to set whether acceptance of the terms and share is required, the settings allowed are acceptance_required
and acceptance_not_required
. Before the recipient of the share can view the data they must explicitly accept the share and it's terms via a second API call. For convenience when using the cli we have automatically set this feild to acceptance_required
when any terms are specified.
Sharing Mode
When a user shares an item with another user there is an option to allow or dis-allow sharing of that item with another person, this is called the "sharing mode". The sharing mode currently has two options available on it, either owner
or anyone
. The owner
sharing mode means the share can not be on-shared to another user. The anyone
option means that the item can be on-shared to anyone. While the system will allow any on-sharing to happen when the sharing mode is set to anyone
it is also important to check the terms
that have set on the share. For convenience in the cli we have added the flag --onshare
which will set the sharing_mode
to anyone
if it is present and set it to owner
if it is not present.
Client Tasks
Due to use of e2e (end to end) encryption the client (client application) is the only place where data can be decrypted and re-encrypted. Sometimes there are tasks that do not need to happen right away when an action takes place but they will need to be done on the client at some point. An example of this is updating shares, for example...
If a Alice has shared an item with Bob and some time later Alice changes the data in the shared item the share will also need to be updated.
The data in Alice's items is encrypted with a DEK (data encryption key) that only Alice has access to, this means the server can not re-encrypt the data with a shared DEK on behalf of Alice, instead the server creates a ClientTask
.
Periodically Alice's client will check to see if there are any ClientTask
s that need to be executed.
Alice's client will pick up the ClientTask
of type update_shares
which will tell it to download and decrypt the modified item then re-encrypt the data with a shared DEK and update the share with the new data.
Example of On-sharing and Executing Client Tasks
(it's recommended to complete the getting-started/quickstart guide before follwing this example)
(NOTE: each user will see the shared item as different item_id
, when referencing the item by id be sure to use the item_id
applicable to the user making the request)
First lets create three users.
Next lets connect Alice to Bob, then Bob to Carlos.
We create an item for Alice.
Share that item from Alice to Bob, with some share terms
, acceptance_required
, and sharing mode of anyone
.
Read the share as Bob.
You will get a result something like the following...
Note the share_id from above.
Bob can have a look at the details and specifically the terms
of the share by getting the share's details with the command.
Note that the item slot details are not available to Bob until he accepts the share and it's terms.
Next Bob will accept the share from Alice.
Bob can now pull down the item's details. (Note: the item id must come from the item when performing the items:list command, the item_id in the shares:accept command will not work).
Now Bob can share this item with Carlos.
Carlos can now see the share.
Returning something like...
Noting the share_id and item_id from the above command.
Accept it.
And view it.
Getting the output something like...
So now we have an Item on-shared from Alice to Bob to Carlos. What if Alice now wants to update the item and get Bob and Carlos the updated data?
First Alice updates the item.
Ok, the item has been updated at this stage but not the shares. Note that the last line of the items:update
command showed a comment saying
If we request the list of Client tasks with the following command...
We will see a list of ClientTasks that are outstanding something like the following.
What we need to do next is re-encrypt all the new data with a new DEK to share with both Bob and Carlos.
We can do this by running the command.
You will see the output something like the following.
Now Carlos and Bob have the updated shared data, you can check that by running the commands.
Hopefully this guide has given you a decent high level overview of how the process works. To dig further into the functionality why not try checking out how the CLI (https://github.com/Meeco/js-sdk/tree/master/packages/cli) uses the underlying SDK (https://github.com/Meeco/js-sdk/tree/master/packages/sdk).
Last updated