import type { AxiosAuthRefreshRequestConfig } from 'axios-auth-refresh'; import { AuthRecoverRequest, AuthTokenRequest, AuthTokenResponse, Base64String, IdentityCreateRequest, IdentityResendConfirmEmailRequest, IdentityResponse, IdentityUpdateRequest, M2MTokenRequest, QRCodeResponse, Tokens, Uuid, WhoAmIResponse } from '../models'; import { APIService } from './api'; export interface GuardRequestConfig extends AxiosAuthRefreshRequestConfig { useRefreshToken: boolean; } export declare class GuardService { private api; private baseURL; private identityCache; private whoAmICache; constructor(api: APIService, baseURL: string); /** * Will replace access and refresh tokens with `tokens` * * Note: * ```typescript * setTokens({accessToken: undefined, refreshToken: 'aTokenValue'}) // will erase accessToken and set refreshToken with 'aTokenValue' * setTokens({refreshToken: 'aTokenValue'}) // will keep actual value of accessToken and set refreshToken with 'aTokenValue' * * ``` * @param tokens */ setTokens(tokens: Tokens): void; /** * Allow to retrieve a M2M token for a service * * @param req The credentials required to get an access token * @returns AuthTokenResponse */ m2mToken(req: M2MTokenRequest): Promise; /** * Allow to retrieve an access token and a refresh token in order * to do authenticated request afterward * * @param req The credentials required to get an access token * @returns AuthTokenResponse */ authToken(req: AuthTokenRequest): Promise; /** * Get new access and refresh token * * @returns AuthTokenResponse */ authRefresh(refreshToken?: string): Promise; /** * Call guard to overwrite existing refresh token cookie * * @returns void */ authLogout(): Promise; /** * Call guard to attempt account recovery * * @param req The email address / practice of the account to recover * @returns void */ authRecover(req: AuthRecoverRequest): Promise; /** * Allow to create a new identity. The identity will then need to be confirmed * via an email link * * @param req the information about the new identity to create * @returns IdentityResponse */ identityCreate(req: IdentityCreateRequest): Promise; /** * Retrieve an identity. Will return public fields only when requested * without authentication * * @param identityID Unique id of the identity to retrieve * @param skipCache (default: false) will skip identity cache (not even update it) * @returns IdentityResponse */ identityGet(identityID: Uuid, skipCache?: boolean): Promise; /** * Get information about the current authenticated user * * @param refreshCache if true it will refresh the whoAmI cache (default: false) * @returns WhoAmIResponse */ whoAmI(refreshCache?: boolean): Promise; /** * Update an existing identity * * @param identityID unique id of identity to update * @param req update request * @returns IdentityResponse */ identityUpdate(identityID: Uuid, req: IdentityUpdateRequest): Promise; /** * Return base64 data representing a QR code that the * current identity need in order to use MFA * * @param identityID unique id of the identity * @param password the identity password (already hashed and in base64) * @returns QRCodeResponse */ identityMFAQRCode(identityID: Uuid, password: Base64String): Promise; /** * Attempt to resend the email confirmation email * * @param req IdentityResendConfirmEmailRequest * @return void */ identitySendConfirmEmail(req: IdentityResendConfirmEmailRequest): Promise; /** * Notifies the guard and confirms the phishing attempt * @param attemptUuid the guard logged attempt id * @returns void */ authConfirmPhishingAttempts(attemptUuid: Uuid): Promise; /** * Get an identity using a customer email (format: customer+[b64Hash]@orohealth.me) * * @param email the customer email * @returns IdentityResponse */ identityGetByCustomerEmail(email: string): Promise; /** * Get an identity using a base64 hash * * @param b64Hash base64 hash of the identity * @returns IdentityResponse */ identityGetByHash(b64Hash: string): Promise; }