disablePermission
disablePermission
function allows disabling permission within the RBAC (Role-Based Access Control) system. This function returns a JSON object with permission ID.
Parameters:
permissionId (type: string, required)
: ID of the permission to be disabled.address (type: Address, optional)
: address associated with the operation. This parameter is not required.seed (type: string, optional)
: mnemonic seed. This parameter is not required.
Code example
import { Sdk } from "@peaq-network/sdk";
/**
* Disables a permission within the RBAC system.
* @param {string} permissionId - The ID of the permission to be disabled (required).
* @param {Address} [address] - The address associated with the operation (not required).
* @param {string} [seed] - The mnemonic seed (not required).
* @returns {Promise<Object>} A promise that resolves to an object containing a message field.
*/
const disablePermission = async (permissionId, seed) => {
const sdkInstance = await Sdk.createInstance({
baseUrl: "wss://wsspc1-qa.agung.peaq.network",
seed,
});
try {
await sdkInstance.connect();
const result = await sdkInstance.rbac.disablePermission({
permissionId: permissionId,
});
return result;
} finally {
await sdkInstance.disconnect();
}
};
// Example usage
const permissionId = '18709409-bc06-4444-2222-b4zz0000';
const seed = "your-seed-phrase";
// Use the function to disable a permission.
disablePermission(permissionId, mnemonicSeed)
.then((result) => {
console.log(`Disabled permission: ${result}`);
})
.catch((error) => {
console.error(`Error disabling permission: ${error}`);
});
Response object
{
message: "Successfully disable permission 18709409-bc06-4444-2222-b4zz0000"
}