import { EventTypes } from './constants'; import { EventEmitter } from './helpers'; import { AuthRequestOptions, IPlusAuthClientOptions, LogoutRequestOptions, PopupOptions, RevokeOptions, TokenType } from './interfaces'; /** * `OIDCClient` provides methods for interacting with OIDC/OAuth2 authorization server. Those methods are signing a * user in, signing out, managing the user's claims, checking session and managing tokens returned from the * OIDC/OAuth2 provider. * */ export declare class OIDCClient extends EventEmitter { options: IPlusAuthClientOptions; user?: any; scopes?: string[]; accessToken?: string; refreshToken?: string; idToken?: string; issuer_metadata?: Record; private readonly http; private synchronizer; private stateStore; private authStore; private sessionCheckerFrame?; private _accessTokenExpireTimer?; private initialized; private __initializePromise; constructor(options: IPlusAuthClientOptions); /** * Initialize the library with this method. It resolves issuer configuration, jwks keys which are necessary for * validating tokens returned from provider and checking if a user is already authenticated in provider. * * @param checkLogin Make this `false` if you don't want to check user authorization status in provider while * initializing. Defaults to `true` */ initialize(checkLogin?: boolean): Promise | never; /** * Redirect to provider's authorization endpoint using provided parameters. You can override any parameter defined * in `OIDCClient`. If you don't provide `state`, `nonce` or `code_verifier` they will be generated automatically * in a random and secure way. * * @param options * @param localState */ login(options?: Partial, localState?: Record): Promise; /** * Open a popup with the provider's authorization endpoint using provided parameters. You can override any * parameter defined in `OIDCClient`. If you don't provide `state`, `nonce` or `code_verifier` they will be * generated automatically in a random and secure way. You can also override popup options. * * NOTE: Most browsers block popups if they are not happened as a result of user actions. In order to display * login popup you must call this method in an event handler listening for a user action like button click. * * @param options * @param popupOptions */ loginWithPopup(options?: Partial, popupOptions?: PopupOptions): Promise; /** * After a user successfully authorizes an application, the authorization server will redirect the user back to * the application with either an authorization code or access token in the URL. In the callback page you should * call this method. * * @param url Full url which contains authorization request result parameters. Defaults to `window.location.href` */ loginCallback(url?: string): Promise; /** * Redirect to provider's `end_session_endpoint` with provided parameters. After logout provider will redirect to * provided `post_logout_redirect_uri` if it provided. * @param options */ logout(options?: LogoutRequestOptions): Promise; /** * OAuth2 token revocation implementation method. See more at [tools.ietf.org/html/rfc7009](https://tools.ietf.org/html/rfc7009) * @param token Token to be revoked * @param type Passed token's type. It will be used to provide `token_type_hint` parameter. * @param options If necessary override options passed to `OIDCClient` by defining them here. */ revokeToken(token: string, type?: TokenType, options?: RevokeOptions): Promise; /** * Login without having an interaction. If refresh tokens are used and there is a stored refresh token it will * exchange refresh token to receive new access token. If not it silently makes a request the provider's * authorization endpoint using provided parameters. You can override any parameter defined in `OIDCClient`. If * you don't provide `state`, `nonce` or `code_verifier` they will be generated automatically in a random and * secure way. * * @param options * @param localState */ silentLogin(options?: AuthRequestOptions, localState?: Record): Promise; /** * Retrieve logged in user's access token if it exists. */ getAccessToken(): Promise; /** * Retrieve logged in user's refresh token if it exists. */ getRefreshToken(): Promise; /** * Retrieve logged in user's parsed id token if it exists. */ getIdToken(): Promise; /** * Retrieve logged in user's id token in raw format if it exists. */ getIdTokenRaw(): Promise; /** * Retrieve logged in user's scopes if it exists. */ getScopes(): Promise; /** * Retrieve logged in user's profile. */ getUser(): Promise; /** * If there is a user stored locally return true. Otherwise it will make a silentLogin to check if End-User is * logged in provider. * * @param localOnly Don't check provider */ isLoggedIn(localOnly?: boolean): Promise; /** * Create authorization request with provided options. * * @param options * @param localState * @private */ private createAuthRequest; /** * Create a logout request with given options * * @param options * @private */ private createLogoutRequest; /** * Exchange authorization code retrieved from auth request result. * @param options * @private */ private exchangeAuthorizationCode; /** * Exchange refresh token with given options * @param options * @private */ private exchangeRefreshToken; /** * Fetch OIDC configuration from the issuer. */ private fetchFromIssuer; /** * Handle auth request result. If there is `code` exchange it. * @param response * @param finalOptions * @param localState * @private */ private handleAuthResponse; /** * Handle OAuth2 auth request result * @param tokenResult * @param authParams * @param finalOptions * @private */ private handleTokenResult; /** * Load stored state * * @param state * @private */ private loadState; /** * Load user info by making request to providers `userinfo_endpoint` * * @param accessToken * @private */ private fetchUserInfo; /** * Start monitoring End-User's session if the OIDC provider supports session management. See more at [OIDC Session * Management](https://openid.net/specs/openid-connect-session-1_0.html) * * @param sub End-User's id to for monitoring session * @param session_state string that represents the End-User's login state at the OP */ private monitorSession; private onUserLogin; } //# sourceMappingURL=client.d.ts.map