Class

Permissions

Permissions()

The permissions data structure.

In Nillion, every stored secret has associated a set of permissions upon creation. If no permissions are provided, the network will grant ownership as well as update, delete and retrieve permissions to the user storing the secret.

For each compute operation, the secrets need to have granted compute permissions for the program and the user accessing the secret for the purpose of a computation.

Permissions for any store value can be updated and retrieved by the owner using update_permissions and retrieve_permissions operations respectively.

Constructor

# new Permissions()

Build a new empty instance of Permissions

View Source nillion_client_wasm.js, line 1709

Example
const permissions = new Permissions();

Classes

Permissions

Methods

# add_compute_permissions(permissions)

Add compute permissions to the Permissions instance for the given list of user IDs

Parameters:
Name Type Description
permissions any

object where the keys are the user identities and for each key the values are a list of program identifiers that user will be granted compute permission for.

View Source nillion_client_wasm.js, line 1847

Example
const permissions = Permissions.default_for_user(nillionClient.user_id);
permissions.add_compute_permissions({
    "user_id": ["program_id"]
});

# add_delete_permissions(user_ids)

Add delete permissions to the Permissions instance for the given list of user IDs

Parameters:
Name Type Description
user_ids Array.<string>

The list of user identifiers that will be granted delete permissions

View Source nillion_client_wasm.js, line 1819

Example
const permissions = Permissions.default_for_user(nillionClient.user_id);
permissions.add_delete_permissions(["user_id"]);

# add_retrieve_permissions(user_ids)

Add retrieve permissions to the Permissions instance for the given list of user IDs

Parameters:
Name Type Description
user_ids Array.<string>

The list of user identifiers that will be granted retrieve permissions

View Source nillion_client_wasm.js, line 1769

Example
const permissions = Permissions.default_for_user(nillionClient.user_id);
permissions.add_retrieve_permissions(["user_id"]);

# add_update_permissions(user_ids)

Add update permissions to the Permissions instance for the given list of user IDs

Parameters:
Name Type Description
user_ids Array.<string>

The list of user identifiers that will be granted update permissions

View Source nillion_client_wasm.js, line 1794

Example
const permissions = Permissions.default_for_user(nillionClient.user_id);
permissions.add_update_permissions(["user_id"]);

# is_compute_allowed(user_id, program) → {boolean}

Returns true if user has compute permissions for every single program

Parameters:
Name Type Description
user_id string

the user identifier

program string

the program identifier

View Source nillion_client_wasm.js, line 1919

true if the user has compute permissions

boolean
Example
const permissions = Permissions.default_for_user(nillionClient.user_id);
const compute_allowed = permissions.is_compute_allowed("user_id", "program_id");

# is_delete_allowed(user_id) → {boolean}

Returns true if user has delete permissions

Parameters:
Name Type Description
user_id string

the user identifier

View Source nillion_client_wasm.js, line 1902

true if the user has delete permissions

boolean
Example
const permissions = Permissions.default_for_user(nillionClient.user_id);
const delete_allowed = permissions.is_delete_allowed("user_id");

# is_retrieve_allowed(user_id) → {boolean}

Returns true if user has retrieve permissions

Parameters:
Name Type Description
user_id string

the user identifier

View Source nillion_client_wasm.js, line 1870

true if the user has retrieve permissions

boolean
Example
const permissions = Permissions.default_for_user(nillionClient.user_id);
const retrieve_allowed = permissions.is_retrieve_allowed("user_id");

# is_update_allowed(user_id) → {boolean}

Returns true if user has update permissions

Parameters:
Name Type Description
user_id string

the user identifier

View Source nillion_client_wasm.js, line 1886

true if the user has update permissions

boolean
Example
const permissions = Permissions.default_for_user(nillionClient.user_id);
const update_allowed = permissions.is_update_allowed("user_id");

# static default_for_user(user_id) → {Permissions}

Builds a new instance of Permissions with the default set for the user identifier.

By default, the user identifier will be granted ownership of the secret as well as full access to the secret. No compute permissions are granted by default unless a program is specified. They need to be assigned separately.

Parameters:
Name Type Description
user_id string

The Nillion user identifier

View Source nillion_client_wasm.js, line 1753

An instance of Permissions with the default configuration for the user

Permissions
Example
const permissions = Permissions.default_for_user(nillionClient.user_id);