authelia/web/src/services/Consent.ts
Amir Zarrinkafsh 3494353641
refactor(web): use absolute imports with aliases (#2100)
* refactor(web): use absolute imports with aliases

Refactors all of the TS/JS frontend to utilise absolute imports along with import aliases.
Each of the paths within `src` are represented with their own alias:

* @assets
* @components
* @constants (new)
* @hooks
* @layouts
* @models
* @services
* @themes
* @utils
* @views

`Routes.ts` and `constant.ts` have been relocated to the constants directory for consistency.
2021-06-19 10:20:43 +02:00

43 lines
1.0 KiB
TypeScript

import { ConsentPath } from "@services/Api";
import { Post, Get } from "@services/Client";
interface ConsentPostRequestBody {
client_id: string;
accept_or_reject: "accept" | "reject";
}
interface ConsentPostResponseBody {
redirect_uri: string;
}
interface ConsentGetResponseBody {
client_id: string;
client_description: string;
scopes: Scope[];
audience: Audience[];
}
interface Scope {
name: string;
description: string;
}
interface Audience {
name: string;
description: string;
}
export function getRequestedScopes() {
return Get<ConsentGetResponseBody>(ConsentPath);
}
export function acceptConsent(clientID: string) {
const body: ConsentPostRequestBody = { client_id: clientID, accept_or_reject: "accept" };
return Post<ConsentPostResponseBody>(ConsentPath, body);
}
export function rejectConsent(clientID: string) {
const body: ConsentPostRequestBody = { client_id: clientID, accept_or_reject: "reject" };
return Post<ConsentPostResponseBody>(ConsentPath, body);
}