(scopeId: string)
| 45 | // --------------------------------------------------------------------------- |
| 46 | |
| 47 | export const parseScope = (scopeId: string): OwnerKeys | null => { |
| 48 | if (scopeId.startsWith("user-org:")) { |
| 49 | const parts = scopeId.split(":"); |
| 50 | if (parts.length !== 3) return null; |
| 51 | const [, user, org] = parts; |
| 52 | if (!user || !org || !user.startsWith("user_") || !org.startsWith("org_")) return null; |
| 53 | return { owner: "user", subject: user, tenant: org }; |
| 54 | } |
| 55 | if (scopeId.startsWith("org_") && !scopeId.includes(":")) { |
| 56 | return { owner: "org", subject: ORG_SUBJECT, tenant: scopeId }; |
| 57 | } |
| 58 | return null; |
| 59 | }; |
| 60 | |
| 61 | export type ScopeOwnerResolver = (scopeId: string) => OwnerKeys | null; |
| 62 |
no outgoing calls
no test coverage detected