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-10-20 02:16:36 +00:00
|
|
|
interface CompletePushSignInBody {
|
2019-11-18 23:37:36 +00:00
|
|
|
targetURL?: string;
|
2022-07-26 05:43:39 +00:00
|
|
|
workflow?: string;
|
2022-10-20 02:16:36 +00:00
|
|
|
workflowID?: string;
|
2019-11-18 23:37:36 +00:00
|
|
|
}
|
|
|
|
|
2022-10-20 02:16:36 +00:00
|
|
|
export function completePushNotificationSignIn(targetURL?: string, workflow?: string, workflowID?: string) {
|
|
|
|
const body: CompletePushSignInBody = {
|
|
|
|
targetURL: targetURL,
|
|
|
|
workflow: workflow,
|
|
|
|
workflowID: workflowID,
|
|
|
|
};
|
2022-07-26 05:43:39 +00:00
|
|
|
|
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
|
|
|
}
|