# new Permissions()
Build a new empty instance of Permissions
Example
const permissions = new Permissions();
Classes
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. |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
An instance of Permissions with the default configuration for the user
Example
const permissions = Permissions.default_for_user(nillionClient.user_id);