I use the SharePoint Framework because I want to access Teams messages through the Graph API using the MSGraphClient.
I have two end goals:
I know that the permission scopes have to be approved by an admin in the Sharepoint Admin center. However, I am a little confused regarding the actual scope of these permissions, bear in mind that I need to abide by the local data protection laws, so my app/webpart may not have access to just everything.
I would like to know whether the permissions granted to my MSGraphClient by the Sharepoint Admin can extend beyond the permissions of the currently logged in user. I cannot tell from the documentation in which cases the permissions are delegated and in which cases their are actual application permissions.
For example, if my MSGraphClient is granted the permission "ChannelMessage.Read.All", can the currently logged in user read "all" messages of all users, or only those messages that he actually has access to? Are all of the permissions granted through the Sharepoint Admin Center delegated? Appart from that, if I wanted to have access to messages regardless of the permissions of the currently logged in user, would I need to use an app token from Azure? If so, is it possible to restrict these permissions to only include reading privileges of specific Teams channels?
The permissions of SPFx web part cannot extend beyond the currently logged-in user. To have extended permissions, you need server-side code. In share point, the thing you are looking for is probably called app-only permissions.
For SPFx web part, running in the browser, this is not possible (and does not make any sense because this would immediately compromise the security). Means, SPFx web part cannot do more than a user can do.
For your case, I would build a service, that has all necessary permissions granted. Basically, a normal web app, that is hosted on a server (can be in a form of azure function or a normal web app, i.e. a website), that, when called, would go and archive these messages. This app should have access to all channels it needs to archive. Then this app can provide some API that can be called from your web part (in case you still want a web part)
Then in that server app you can validate if the user has appropriate permissions to do what he's intended to do. You do that in server-side code, to which user has no access. Doing that it in the browser (in JavaScript) does not make any sense because the user has full access to JavaScript in the browser and can edit it any way he wants.