/** * Copyright 2020 Splunk, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"): you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ import { AuthManager as SdkAuthManager } from '@splunkdev/cloud-sdk/src/auth_manager'; import { AccessToken } from './model/access-token'; import { UserState } from './model/user-state'; import { SplunkAuthClientSettings } from './splunk-auth-client-settings'; /** * Error codes that can be handled for redirecting to login. */ export declare const REDIRECT_LOGIN_HANDLED_ERROR_CODES: Set; /** * SplunkAuthClient. */ export declare class SplunkAuthClient implements SdkAuthManager { /** * AuthClient constructor. * @param settings AuthClientSettings. * @param tenant Tenant. * @param region Region. */ constructor(settings: SplunkAuthClientSettings, tenant?: string, region?: string); private _settings; private _tokenManager; private _authManager; private _hasRequestedToken; private _redirectInProgress; private _tenant; private _region; /** * Gets the access token string. */ getAccessToken(): Promise; /** * Gets the full access token context including expiration and scope. * * If a token has been cached in the TokenManager and is still valid, this method returns the cached AccessToken. * If a token is not cached or is expired this method will attempt to retrieve, cache and return an AccessToken * from the Auth Host. * - If token retrieval fails and autoRedirectToLogin is true, this method will redirect to the splunk cloud * login page. Once valid credentials have been entered, the browser will be redirected back to the * previous page. * - If token retrieval fails and autoRedirectToLogin is false, this method will attempt to retrieve a * new token. */ getAccessTokenContext(): Promise; /** * Explicitly clears the access token from storage. */ clearAccessToken(): void; /** * Checks whether the client is authenticated by checking for a token in storage * and comparing against the expiration time. */ isAuthenticated(): boolean; /** * Store window.location path information and initiate the Implicit Flow. * (see: https://developer.okta.com/authentication-guide/implementing-authentication/implicit#2-using-the-implicit-flow) * * If the user does not have an existing session, this will redirect to login Page. If they * have an existing session, or after they log in, they will be redirected back to the * `config.redirectUri` (or `window.location.href` if not specified) and any tokens returned * will be parsed via `this.parseTokensFromRedirect`. */ login(): void; /** * Clear any tokens saved to sessionStorage. Note that session cookies are not cleared. */ logout(url?: any | string): void; /** * Get the tenant information such as the tenant name and the region its in. */ getTenantInfo(): UserState; /** * Redirect the user to sign the Splunk Cloud Services Terms Of Service. */ private redirectToTos; /** * The default function to restore path if config.onRestorePath is not specified. */ private static defaultRestorePath; /** * Check for token returned from a previous redirect, if none then call the /authorize */ private requestToken; /** * Store the complete window.location information so that the state can be restored after the * browser is redirected to the login page and then back here. */ private storePathBeforeLogin; /** * Retrieve the information stored in storePathBeforeLogin to restore the state of this page. */ private restorePathAfterLogin; /** * Get the query string information for the params specified in queryParamsForLogin. * This is used to pass additional information via query params to the log in page. */ private getQueryStringForLogin; }