Create Access or IdAccess objects giving Chum-sync access for a Person or a group to that object or ID object (all versions).
Methods
(async, static) createAccess(accessRequests) → {Promise.<Array.<VersionedObjectResult>>}
Parameters:
Name | Type | Description |
---|---|---|
accessRequests |
Array.<SetAccessParam> | An array of object/person-references Reference objects. For each object access rights are created for the corresponding Person objects. |
Create one Access object for a given versioned ONE object. Access objects have "references"
and not just a simple SHA-256 hash for linkage to the target object because objects should be
linked through reference links, but more importantly, only Reference object links trigger the
writing of reverse maps, which makes it possible to start from a given Person and find all
Access objects that reference it. For any given versioned object find all Access objects
referencing it (granting access to someone).
If the person
or group
array is empty an Access object without grants is created if no
previous Access object existed for the given object. If there already is one and mode
is
mode
is "add" (constant Storage.SET_ACCESS_MODE.ADD
) only a new version map entry is
created, if mode
is "replace" a new most current Access object version is created without
grants, thereby revoking any access rights that may previously have existed.
Returns:
Returns the result of writing the Access object.
Type: Promise.<Array.<VersionedObjectResult>>
Example
// Set access right for two objects (Array of two SetAccessParam objects)
// Result: Array with two VersionedObjectResult<Access> objects
const access: ObjectCreation = await createAccess([
{
object: objectHash,
person: [personIdHash, anotherPersonIdHash],
group: [],
mode: Storage.SET_ACCESS_MODE.ADD
},
{
object: objectHash,
person: personIdHash,
group: [],
mode: Storage.SET_ACCESS_MODE.REPLACE
}
]);