mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +03:00
21 lines
801 B
TypeScript
21 lines
801 B
TypeScript
export const SELF_USAGE_SCOPE = "self:usage";
|
|
export const SELF_ACCOUNT_QUOTA_SCOPE = "self:account-quota";
|
|
|
|
export const DEFAULT_SELF_SERVICE_SCOPES = [SELF_USAGE_SCOPE] as const;
|
|
|
|
export function hasSelfUsageScope(scopes: readonly string[] | null | undefined): boolean {
|
|
return Array.isArray(scopes) && scopes.includes(SELF_USAGE_SCOPE);
|
|
}
|
|
|
|
export function hasSelfAccountQuotaScope(scopes: readonly string[] | null | undefined): boolean {
|
|
return Array.isArray(scopes) && scopes.includes(SELF_ACCOUNT_QUOTA_SCOPE);
|
|
}
|
|
|
|
export function normalizeSelfServiceScopesForCreate(
|
|
scopes: readonly string[] | null | undefined
|
|
): string[] {
|
|
const normalized = new Set((scopes ?? []).filter((scope) => typeof scope === "string" && scope));
|
|
normalized.add(SELF_USAGE_SCOPE);
|
|
return [...normalized];
|
|
}
|