@openpass/openpass-js-sdk
Version:
OpenPass SSO JavaScript SDK
35 lines (34 loc) • 1.52 kB
TypeScript
import { OpenPassApiClient } from "./api/openPassApiClient";
import RedirectAuth from "./redirect";
import AbortablePromise from "./utils/abortablePromise";
import { OpenPassOptions, OpenPassTokens, SignInResponse } from "../types";
import { AuthSession, InternalPopupSignInOptions } from "./internalTypes";
type AuthWindow = {
window: Window;
listener?: AbortablePromise<any>;
};
/**
* Class which handles the Popup authorization flow.
* This class redirects to the authorization server and waits for a response from the authorization server.
* The response is sent via the window.postMessage API to support secure cross-origin communication.
*/
export default class PopupAuth {
private readonly redirectApi;
private readonly openPassApiClient;
private readonly openPassOptions;
private popupWindow?;
constructor(openPassOptions: OpenPassOptions, redirectApi: RedirectAuth, openPassApiClient: OpenPassApiClient);
refocusIfPopupExists(): boolean;
hasActivePopup(): boolean;
signInWithPopup(options: InternalPopupSignInOptions): Promise<SignInResponse>;
private popupCloseHandler;
private doLogin;
addPopupCloseOnBeforeUnloadHandler(): void;
removePopupCloseOnBeforeUnloadHandler(): void;
private waitForPopupResponse;
protected completeAuthentication(authWindow: AuthWindow, tokens: OpenPassTokens, authSession: AuthSession): Promise<SignInResponse>;
private listenForPopupResponse;
private openPopup;
private closePopupIfExists;
}
export {};