HasAcceptedScope checks if any of the provided user scopes satisfy the tool's requirements.
(userScopes ...string)
| 70 | |
| 71 | // HasAcceptedScope checks if any of the provided user scopes satisfy the tool's requirements. |
| 72 | func (t *ToolScopeInfo) HasAcceptedScope(userScopes ...string) bool { |
| 73 | if t == nil || len(t.AcceptedScopes) == 0 { |
| 74 | return true // No scopes required |
| 75 | } |
| 76 | |
| 77 | userScopeSet := make(map[string]bool) |
| 78 | for _, scope := range userScopes { |
| 79 | userScopeSet[scope] = true |
| 80 | } |
| 81 | |
| 82 | for _, scope := range t.AcceptedScopes { |
| 83 | if userScopeSet[scope] { |
| 84 | return true |
| 85 | } |
| 86 | } |
| 87 | return false |
| 88 | } |
| 89 | |
| 90 | // MissingScopes returns the required scopes that are not present in the user's scopes. |
| 91 | func (t *ToolScopeInfo) MissingScopes(userScopes ...string) []string { |
no outgoing calls