Permissions

Permissions

Holds the permissions of a MutableData object

Constructor

new Permissions()

Source:

Methods

getPermissionSet(signKeyopt) → {Promise.<Object>}

Lookup the permissions of a specifc signing key

Parameters:
Name Type Attributes Default Description
signKey PubSignKey | CONSTANTS.USER_ANYONE <optional>
CONSTANTS.USER_ANYONE

The key to lookup

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
       const pubSignKey = await app.crypto.getAppPubSignKey();
       const perms = await mData.getPermissions();
       const permSet = await perms.getPermissionsSet(pubSignKey)
    } catch(err) {
      throw err;
    }
};

insertPermissionSet(signKeyopt, permissionSet) → {Promise}

// Assumes SAFEApp interface has been obtained Insert a new permission set mapped to a specifc key. Directly commits to the network. Requires the 'ManagePermissions' permission for the app.

Parameters:
Name Type Attributes Default Description
signKey PubSignKey | CONSTANTS.USER_ANYONE <optional>
CONSTANTS.USER_ANYONE

the key to map to

permissionSet Object

The permission set to insert

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
       const pubSignKey = await app.crypto.getAppPubSignKey();
       const perms = await mData.getPermissions();
       const pmSet = ['Insert', 'ManagePermissions'];
       await perms.insertPermissionSet(pubSignKey, pmSet)
    } catch(err) {
      throw err;
    }
};

len() → {Promise.<Number>}

Total number of permission entries

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
      const mData = await app.mutableData.newRandomPublic(15001);
      await mData.quickSetup({});
      const perms = await mData.getPermissions();
      const length = await perms.len();
    } catch(err) {
      throw err;
    }
};

listPermissionSets() → {Promise.<Array>}

Return the list of all associated permission sets.

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
       const mData = await app.mutableData.newRandomPublic(15001);
       await mData.quickSetup({});
       const perms = await mData.getPermissions();
       const permSetsArray = await perms.listPermissionSets();
    } catch(err) {
      throw err;
    }
};