|
|
|
@ -64,7 +64,9 @@ export const SCOPES_OF_READ_RESTRICTED_ACCESS: readonly Scope[] = |
|
|
|
/** |
|
|
|
* Maximum scopes per access type. The scopes stored on an access are |
|
|
|
* intersected with it, hence a scope which the type does not permit stays |
|
|
|
* ineffective even if it is stored. |
|
|
|
* ineffective even if it is stored. A type which cannot grant the restricted |
|
|
|
* write access drops the write scopes in addition, unless the access reads the |
|
|
|
* monetary values. |
|
|
|
*/ |
|
|
|
const SCOPES_OF_TYPE: Record<AccessType, readonly Scope[]> = { |
|
|
|
MCP: [...SCOPES_OF_READ_RESTRICTED_ACCESS, scopes.activityCreate], |
|
|
|
@ -72,6 +74,14 @@ const SCOPES_OF_TYPE: Record<AccessType, readonly Scope[]> = { |
|
|
|
PUBLIC: SCOPES_OF_PUBLIC_ACCESS |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Access types which combine a write scope with the restricted read access, |
|
|
|
* because their tools change data without exposing the monetary values |
|
|
|
*/ |
|
|
|
export function canGrantRestrictedWriteAccess({ type }: { type: AccessType }) { |
|
|
|
return type === 'MCP'; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Access level which the scopes of an access grant |
|
|
|
*/ |
|
|
|
@ -96,10 +106,8 @@ export function getScopesOfAccess({ |
|
|
|
}): string[] { |
|
|
|
const scopesToEvaluate = scopesOfAccess ?? []; |
|
|
|
|
|
|
|
// The type PRIVATE has no restricted write level, hence a write scope stays
|
|
|
|
// ineffective without the scope to read the monetary values
|
|
|
|
const permitsWriteAccess = |
|
|
|
type !== 'PRIVATE' || |
|
|
|
canGrantRestrictedWriteAccess({ type }) || |
|
|
|
hasScope(scopesToEvaluate, scopes.portfolioReadValues); |
|
|
|
|
|
|
|
// An unknown scope is dropped
|
|
|
|
|