toShellGrants function
Translates OmnyServer's token grants into OmnyShell's.
The two are the same shape but distinct types — each package predates the
other's dependency — except that OmnyShell's carries a displayName, which
it shows to operators. OmnyServer has no such field, so the principal id
stands in for it.
Implementation
Map<String, omnyshell.TokenGrant> toShellGrants(
Map<String, TokenGrant> grants,
) {
return {
for (final entry in grants.entries)
entry.key: omnyshell.TokenGrant(
principal: omnyshell.PrincipalId(entry.value.principal.value),
displayName: entry.value.principal.value,
roles: entry.value.roles,
),
};
}