import { ClientOptions, GetTokenOptions, GetTokenVerboseResponse, LogoutOptions, RedirectLoginOptions, PopupLoginOptions, iframeLoginOptions, checkAuthOptions } from './utils/definitions'; export default class Client { private readonly transactionManager; private readonly cacheManager; private readonly cookieStorage; private readonly nowProvider; private readonly httpTimeoutMs; private readonly domainUrl; private readonly scope; private readonly authorities; private readonly tokenCookieName; private readonly options; private _cacheSetupDone; constructor(options: ClientOptions); private _initializeCache; private _url; private _authorizeUrl; private _prepareAuthorizeUrl; private _saveEntryInCache; /** * save created_at for refresh token expiration check */ private _saveEntryInMemoryOnly; private _requestToken; private _requestTokenViaRefreshToken; private _getSGTokenFromParent; /** * ```js * await viverse.loginWithRedirect(options); * ``` * * Performs a redirect to `/SS/Services/OAuth/Authorize` using the parameters * provided as arguments. Random and secure `state` and `nonce` * parameters will be auto-generated. * * @param options */ loginWithRedirect(options?: RedirectLoginOptions): Promise; /** * After the browser redirects back to the callback page, * call `handleRedirectCallback` to handle success and error * responses from HTC Account. If the response is successful, results * will be valid according to their expiration times. */ handleRedirectCallback(url?: string): Promise<{ state: string; access_token: string; account_id: string; expires_in: number; }>; /** * ```js * await viverse.loginWithPopup(); * ``` * * First, will check if there is a first-party Authkey in the cookies. To make sure account ID is consistent across the main site and the viverse sso sdk. * If not, will check if there is a third-party access token in the cache. * If neither is found, it performs a popup to viverse-web for user authentication. * * @param options * @param {string} [options.htcAccessTokenName] - for local development purposes only, do NOT document externally. * @param {string} [options.viverseDomain] - for local development purposes only, do NOT document externally. * @param {string} [options.authorities] - for local development purposes only, do NOT document externally. * */ loginWithPopup(options?: PopupLoginOptions): Promise<{ access_token: string; account_id: string; expires_in: number; }>; getToken(options?: GetTokenOptions): Promise; getTokenViaRefreshToken(options?: GetTokenOptions): Promise; /** * @param options */ private _buildLogoutUrl; /** * @param options */ logout(options: LogoutOptions): Promise; /** * ```js * await viverse.checkAuth(); * ``` * * check third-party access token for standalone app * * @param options * @param {number} [options.timeout] - in milliseconds, defaults to 60000 (60 seconds). * @param {string} [options.allowedOrigin] - for local development purposes only, do NOT document externally. * */ checkAuth(options?: checkAuthOptions): Promise<{ access_token?: string; account_id?: string; expires_in?: number; state?: string; } | undefined>; /** * login for standalone app * Send a postMessage to parent window to request login */ loginWithWorlds(options?: iframeLoginOptions): void; /** * logout for standalone app, clear memory cache * Send a postMessage to parent window to request logout */ logoutWithWorlds(): Promise; private _getEntryFromCache; private _waitForCacheSetup; }