A share instance provides an API to interact with a share. It's extending the default Remote Store by methods to grant or revoke read / write access.
By default, a share is only accessible to me. If I want
it to share it, I explicatly need to grant access
by calling share.grantReadAccess(). I can also grant
access to only specific users by passing an array:
share.grantReadAccess(['joe','lisa'])
It's plannend to secure a public share with a password, but this feature is not yet implemented.
To subscribe to a share created by somebody else, run
this code: hoodie.share('shareId').subscribe().
initializes a new share
make sure that we have an id
set name from id
set prefix from name
set options
shares are not accessible to others by default.
grant read access to the share. If no users passed, everybody can read the share objects. If one or multiple users passed, only these users get read access.
examples:
share.grantReadAccess()
share.grantReadAccess('joe@example.com')
share.grantReadAccess(['joe@example.com', 'lisa@example.com'])
revoke read access to the share. If one or multiple users passed, only these users' access gets revoked. Revoking reading access always includes revoking write access as well.
examples:
share.revokeReadAccess()
share.revokeReadAccess('joe@example.com')
share.revokeReadAccess(['joe@example.com', 'lisa@example.com'])
grant write access to the share. If no users passed, everybody can edit the share objects. If one or multiple users passed, only these users get write access. Granting writing reads always also includes reading rights.
examples:
share.grantWriteAccess()
share.grantWriteAccess('joe@example.com')
share.grantWriteAccess(['joe@example.com', 'lisa@example.com'])
revoke write access to the share. If one or multiple users passed, only these users' write access gets revoked.
examples:
share.revokeWriteAccess()
share.revokeWriteAccess('joe@example.com')
share.revokeWriteAccess(['joe@example.com', 'lisa@example.com'])
a db _security response looks like this:
{
members: {
names: [],
roles: ["1ihhzfy"]
},
writers: {
names: [],
roles: ["1ihhzfy"]
}
}
we want to turn it into
{read: true, write: true}
given that users ownerHash is "1ihhzfy"
Share Instance