// Copyright © 2022-2026 Partium, Inc. DBA Partium import { SessionService, LoginConfig, LogoutConfig } from './session.service.interface'; import { Observable } from 'rxjs'; import { ServiceProvider } from '../service-provider'; /** * Configuration that is needed for oauth login. */ export declare class OauthLoginConfig extends LoginConfig { apiKey?: string; activeSession?: OauthStatus; constructor(init?: Partial); } export declare class OauthStatus { accessToken: string; accessTokenExpiration: Date; accessTokenCreateDate: Date; authenticated: boolean; refreshToken: string; constructor(init?: Partial); } /** * Oauth specific extension of the SessionService, that provides functions * for oauth-authentication. * The implementations of this interface will be based on the chosen * platform that is used in the application, * * An implementation of this service is required and has to be configured during * the initialization phase of Partium. * * This class file is called interface, even though it is not an interface, * but we need it to be a concrete class for the serviceProvider. */ export declare abstract class OauthSessionService extends SessionService { private httpsServiceOauth; constructor(serviceProvider: ServiceProvider); onCreate(): void; /** * Returns the current OauthState by returning the OauthStatus object. * * @abstract * @returns {Observable} */ abstract getStatus(): Observable; /** * Log in the user and will resolve on success, throw an error otherwise * If an apiKey is passed in the config, the login should be done automatically, * otherwise the user should be prompted to enter login credentials. * * Make sure to call this.sessionSetup() on successful login, to prepare * the current session. * * Method should be overridden by child-class * * @param config the LoginConfiguration * @returns {Observable} */ login(config: OauthLoginConfig): Observable; /** * Refresh the token using the refreshToken. As login, will resolve on success or throw otherwise * * Method should be overridden by child-class */ refresh(): Observable; /** * Logout the user and remove all locally stored information. Next login should require the user to enter the credentials * * Method should be overridden by child-class * * @returns {Observable} */ logout(config?: LogoutConfig): Observable; /** * Update the oauth token in the oauth https service whenever it changes. */ protected tokenUpdated(newToken: string, tokenExpiresAt: Date): void; }