2021-12-01 03:32:58 +00:00
|
|
|
import {
|
|
|
|
CompletePushNotificationSignInPath,
|
|
|
|
InitiateDuoDeviceSelectionPath,
|
|
|
|
CompleteDuoDeviceSelectionPath,
|
|
|
|
} from "@services/Api";
|
|
|
|
import { Get, PostWithOptionalResponse } from "@services/Client";
|
2019-11-18 23:37:36 +00:00
|
|
|
|
|
|
|
interface CompleteU2FSigninBody {
|
|
|
|
targetURL?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function completePushNotificationSignIn(targetURL: string | undefined) {
|
|
|
|
const body: CompleteU2FSigninBody = {};
|
|
|
|
if (targetURL) {
|
|
|
|
body.targetURL = targetURL;
|
|
|
|
}
|
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[];
|
|
|
|
}
|
|
|
|
export async function initiateDuoDeviceSelectionProcess() {
|
|
|
|
return Get<DuoDevicesGetResponse>(InitiateDuoDeviceSelectionPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DuoDevicePostRequest {
|
|
|
|
device: string;
|
|
|
|
method: string;
|
|
|
|
}
|
|
|
|
export async function completeDuoDeviceSelectionProcess(device: DuoDevicePostRequest) {
|
|
|
|
return PostWithOptionalResponse(CompleteDuoDeviceSelectionPath, { device: device.device, method: device.method });
|
2021-01-02 10:58:24 +00:00
|
|
|
}
|