src/authorization-types.tsTypeScript
@@ -0,0 +1,25 @@
1+
export interface AuthorizationRequest {2+
tenantId: string;3+
userId: string;4+
resourceId: string;5+
action: "read" | "write" | "delete";6+
policyVersion: number;7+
}8+
9+
export interface AuthorizationDependencies {10+
cache: {11+
get(key: string): Promise<boolean | undefined>;12+
set(key: string, allowed: boolean, ttlSeconds: number): Promise<void>;13+
removeByPrefix(prefix: string): Promise<void>;14+
};15+
evaluator: {16+
evaluate(request: AuthorizationRequest): Promise<boolean>;17+
};18+
}19+
20+
export interface RoleUpdateDependencies {21+
roles: {22+
update(tenantId: string, userId: string, roles: string[]): Promise<void>;23+
};24+
cache: AuthorizationDependencies["cache"];25+
}