2021-12-01 03:32:58 +00:00
|
|
|
import {
|
2022-08-18 09:13:10 +00:00
|
|
|
CompleteDuoDeviceSelectionPath,
|
2021-12-01 03:32:58 +00:00
|
|
|
CompletePushNotificationSignInPath,
|
|
|
|
InitiateDuoDeviceSelectionPath,
|
|
|
|
} from "@services/Api";
|
|
|
|
import { Get, PostWithOptionalResponse } from "@services/Client";
|
2019-11-18 23:37:36 +00:00
|
|
|
|
2022-03-03 11:20:43 +00:00
|
|
|
interface CompletePushSigninBody {
|
2019-11-18 23:37:36 +00:00
|
|
|
targetURL?: string;
|
2022-07-26 05:43:39 +00:00
|
|
|
workflow?: string;
|
2019-11-18 23:37:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-26 05:43:39 +00:00
|
|
|
export function completePushNotificationSignIn(targetURL?: string, workflow?: string) {
|
2022-03-03 11:20:43 +00:00
|
|
|
const body: CompletePushSigninBody = {};
|
2019-11-18 23:37:36 +00:00
|
|
|
if (targetURL) {
|
|
|
|
body.targetURL = targetURL;
|
|
|
|
}
|
2022-07-26 05:43:39 +00:00
|
|
|
|
|
|
|
if (workflow) {
|
|
|
|
body.workflow = workflow;
|
|
|
|
}
|
|
|
|
|
2021-12-01 03:32:58 +00:00
|
|
|
return PostWithOptionalResponse<DuoSignInResponse>(CompletePushNotificationSignInPath, body);
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DuoSignInResponse {
|
|
|
|
result: string;
|
|
|
|
devices: DuoDevice[];
|
|
|
|
redirect: string;
|
|
|
|
enroll_url: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DuoDevicesGetResponse {
|
|
|
|
result: string;
|
|
|
|
devices: DuoDevice[];
|
|
|
|
enroll_url: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DuoDevice {
|
|
|
|
device: string;
|
|
|
|
display_name: string;
|
|
|
|
capabilities: string[];
|
|
|
|
}
|
2022-07-26 05:43:39 +00:00
|
|
|
|
2021-12-01 03:32:58 +00:00
|
|
|
export async function initiateDuoDeviceSelectionProcess() {
|
|
|
|
return Get<DuoDevicesGetResponse>(InitiateDuoDeviceSelectionPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DuoDevicePostRequest {
|
|
|
|
device: string;
|
|
|
|
method: string;
|
|
|
|
}
|
2022-07-26 05:43:39 +00:00
|
|
|
|
2021-12-01 03:32:58 +00:00
|
|
|
export async function completeDuoDeviceSelectionProcess(device: DuoDevicePostRequest) {
|
|
|
|
return PostWithOptionalResponse(CompleteDuoDeviceSelectionPath, { device: device.device, method: device.method });
|
2021-01-02 10:58:24 +00:00
|
|
|
}
|