Skip to content

Commit

Permalink
feat: augment permissions (#567)
Browse files Browse the repository at this point in the history
Co-authored-by: Urban Vidovič <[email protected]>
Co-authored-by: martines3000 <[email protected]>
  • Loading branch information
3 people authored Mar 4, 2024
1 parent d1fb6d3 commit fc4e573
Show file tree
Hide file tree
Showing 28 changed files with 1,806 additions and 179 deletions.
9 changes: 9 additions & 0 deletions .changeset/tasty-news-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@blockchain-lab-um/masca-connector': patch
'@blockchain-lab-um/masca-types': patch
'@blockchain-lab-um/dapp': patch
'@blockchain-lab-um/masca-docs': patch
'@blockchain-lab-um/masca': patch
---

Implement new permission system in snap, update connector & types and permissions table on dApp
57 changes: 57 additions & 0 deletions packages/connector/src/snap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,60 @@ async function removeTrustedDapp(
);
}

/**
* Adds a dapp to the settings list.
*
* @return Result<boolean> - true if the addition was successful
*/
async function addDappSettings(
this: Masca,
origin: string
): Promise<Result<boolean>> {
return sendSnapMethod(
this,
{ method: 'addDappSettings', params: { origin } },
this.snapId
);
}

/**
* Removes a dapp from the settings list.
*
* @return Result<boolean> - true if the addition was successful
*/
async function removeDappSettings(
this: Masca,
origin: string
): Promise<Result<boolean>> {
return sendSnapMethod(
this,
{ method: 'removeDappSettings', params: { origin } },
this.snapId
);
}

/**
* Modify permissions for a specific RPC method on a specific dApp. This will disable/enable popups for said method.
*
* Currently changing permissions is only supported for the queryCredentials method.
*
* This method is only available on https://masca.io & https://beta.masca.io
*
* @return Result<boolean> - true if the removal was successful
*/
async function changePermission(
this: Masca,
origin: string,
method: 'queryCredentials',
value: boolean
): Promise<Result<boolean>> {
return sendSnapMethod(
this,
{ method: 'changePermission', params: { origin, method, value } },
this.snapId
);
}

/**
* Get the status of available VC stores (i.e. whether they are enabled or not)
*
Expand Down Expand Up @@ -612,5 +666,8 @@ export class Masca {
exportStateBackup: wrapper(exportStateBackup.bind(this)),
getWalletId: wrapper(getWalletId.bind(this)),
signData: wrapper(signData.bind(this)),
changePermission: wrapper(changePermission.bind(this)),
addDappSettings: wrapper(addDappSettings.bind(this)),
removeDappSettings: wrapper(removeDappSettings.bind(this)),
});
}
Loading

0 comments on commit fc4e573

Please sign in to comment.