@openpass/openpass-js-sdk
Version:
OpenPass SSO JavaScript SDK
25 lines (24 loc) • 1.27 kB
TypeScript
import { OpenPassApiClient } from "./api/openPassApiClient";
import { AuthorizeDeviceData, AuthorizeDeviceOptions, DeviceTokenWithStatus, OpenPassOptions } from "../types";
export default class DeviceAuthGrant {
private readonly openPassApiClient;
private readonly openPassOptions;
/**
* Constructs a new instance of the DeviceAuthGrant class.
* @param OpenPassOptions - The options for OpenPass.
* @param openPassAuthClient - The client for OpenPass API.
*/
constructor(openPassOptions: OpenPassOptions, openPassAuthClient: OpenPassApiClient);
/**
* Authorizes a device via the device authorization grant flow.
* @param options - The options for device authorization.
* @returns A promise that resolves to the data of the authorized device.
*/
authorizeDevice(options: AuthorizeDeviceOptions): Promise<AuthorizeDeviceData>;
/**
* Retrieves the device token for the provided device code, or a status if the authentication is still pending.
* @param deviceCode - The code of the device (which is returned by the authorizeDevice method)
* @returns A promise that resolves to the device token with its status.
*/
deviceToken(deviceCode: string): Promise<DeviceTokenWithStatus>;
}