MindLake.Permission

In Mind Lake, users can access others' data, but private encrypted data is presented as ciphertext. To share private data with a specific user, the data owner must grant the target user permission to decrypt the ciphertext, thereby enabling access to the plaintext.

During testing, only existing users of Mind Lake can be designated as targets for permission sharing.

1. grant() Method

Grant decryption permissions to the recipient to enable them to access the encrypted data in the specified columns.

When the Grant method is called by a grantor for the same recipient again, the existing grant policy from the grantor to the recipient is overwritten. The previous policy becomes invalid immediately, and the new policy, which includes the new set of columns, takes effect only after the recipient invokes the Confirm method for this grant policy.

await mindLake.permission.grant(targetChain, targetWalletAddress, columns)

Parameters

  1. targetChain - string: the target chain ID.

  2. targetWalletAddress - string: the wallet address of the recipient

  3. columns - Array<string>: the columns to be shared with the recipient. Each column should be defined as a string that combines the table name, and column name, separated by dots. Specifically, the format for defining a column should be "TableName.ColumnName"

Returns

An object of Promise<>. For more information.

  • result - string: the UUID string of the grant policy. The granter should share this UUID with the recipient. The recipient then needs to confirm the policy for it to take effect.

Example

const permission = mindLake.permission;
//"5" is example of Goerli Testnet chainId
const chainId = "5"
const res = await permission.grant(chainId,"targetWalletAddress", ["table.column"])
if(res.code === 0) {
    console.log(res.result)
}

2. confirm() Method

Confirm the grant policy as the recipient. The policy will take effect after the confirmation.

await mindLake.permission.Confirm(policyID)

Parameters

  1. policyID - string: the UUID string of the grant policy. The recipient should receive it from the granter.

Returns

An object of Promise<>. For more information.

Example

const permission = mindLake.permission;
const res = await permission.confirm("policyID");
if(res.code === 0) {
    console.log(res.result)
}

3. revoke() Method

Revoke decryption permissions for the target user. Consequently, the target user loses access to all the encrypted data belonging to the owner who invokes this method.

await mindLake.permission.revoke(targetWalletAddress, targetChain, columns)

Parameters

  1. targetWalletAddress - string: the wallet address of the target whose permission is to be revoked.

  2. targetChain - string: the target chain ID.

  3. columns - Array<object>: the columns to be revoked. The target user will lose access to the data in these columns.

Returns

An object of Promise<>. For more information.

Example

const permission = mindLake.permission;
const res = await permission.revoke("targetWalletAddress");
if(res.code === 0) {
    console.log(res.result)
}

4. listGrantee() Method

Retrieve a list of wallet addresses of users who have been granted permission by the invoking user.

await mindLake.permission.listGrantee()

Returns

An object of Promise<>. For more information.

  • result - Array<string>: a list of wallet addresses of users who have been granted permission by the invoking user.

Example

const permission = mindLake.permission;
const res = await permission.listGrantee();
if(res.code === 0) {
    console.log(res.result)
}

5. listOwner() Method

Retrieve a list of wallet addresses of users who have granted permission to the invoking user.

await mindLake.permission.listOwner()

Returns

An object of Promise<>. For more information.

  • result - Array<string>: a list of wallet addresses of users who have granted permission to the invoking user.

Example

const permission = mindLake.permission;
const res = await permission.listOwner();
if(res.code === 0) {
    console.log(res.result)
}

6. listGrantedColumn() Method

Retrieve a list of column names for which decryption permission has been granted to the specified user.

await mindLake.permission.listGrantedColumn(targetWalletAddress, targetChain)

Parameters

  1. targetWalletAddress - string: specify the target user by the wallet address.

  2. targetChain - string:the target chain ID.

Returns

An object of Promise<>. For more information.

  • result - Array<string>: a list of column names for which decryption permission has been granted to the specified user.

Example

const permission = mindLake.permission;
const res = await permission.listGranteeColumn("targetWalletAddress");
if(res.code === 0) {
    console.log(res.result)
}

7. listOwnerColumn() Method

Retrieve a list of column names authorized for decryption by the specified user.

await mindLake.permission.listOwnerColumn(targetWalletAddress, targetChain)

Parameters

  1. targetWalletAddress - string: sspecify the owner user of the authorized columns by the wallet address.

  2. targetChain - string: the target chain ID.

Returns

An object of Promise<>. For more information.

  • result - Array<string>: a list of column names authorized for decryption by the specified user.

Example

const permission = mindLake.permission;
const res = await permission.listOwnerColumn("targetWalletAddress");
if(res.code === 0) {
    console.log(res.result)
}

Last updated