UNPKG

@foxy.io/sdk

Version:

Universal SDK for a full server-side and a limited in-browser access to Foxy hAPI.

63 lines (62 loc) 2.74 kB
import type { Credentials, SignUpParams } from './types'; import type { Graph } from './Graph'; import * as Core from '../core/index.js'; /** * Customer API for adding custom functionality to websites and web apps with our Customer Portal. * * **IMPORTANT**: this client is not compatible with the beta version of Customer API. * If you're still on beta, please consider updating your code to the latest stable version. * You can use @foxy.io/sdk prior to 1.0.0-beta.15 or a custom API client until you transition. */ export declare class API extends Core.API<Graph> { /** Storage key for session data. */ static readonly SESSION = "session"; /** Validators for the method arguments in this class (internal). */ static readonly v8n: { classConstructor: any; } & { signUpParams: any; credentials: any; boolean: any; email: any; }; constructor(params: ConstructorParameters<typeof Core.API>[0]); /** * Creates a Customer Portal session for a customer with the given credentials. * Incorrect email and password will trigger `Core.API.AuthError` with code `UNAUTHORIZED`. * * @param credentials Customer email and password (one-time code). */ signIn(credentials: Credentials): Promise<void>; /** * Creates a new customer account with the given credentials. * If the email is already taken, `Core.API.AuthError` with code `UNAVAILABLE` will be thrown. * If customer registration is disabled, `Core.API.AuthError` with code `UNAUTHORIZED` will be thrown. * If the provided form data is invalid (e.g. captcha is expired), `Core.API.AuthError` with code `INVALID_FORM` will be thrown. * * @param params Customer information. */ signUp(params: SignUpParams): Promise<void>; /** * Initiates password reset for a customer with the given email. * If such customer exists, they will receive an email from Foxy with further instructions. * * @param params Password reset parameters. * @param params.email Customer email. */ sendPasswordResetEmail(params: { email: string; }): Promise<void>; /** Destroys current session and clears local session data. */ signOut(): Promise<void>; /** * When logged in with a temporary password, this property getter will return `true`. * Will return `false` if password reset is not required or if the session has not been * initiated, or if the session was initiated before the introduction of this feature. * * @returns {boolean} Password reset requirement. */ get usesTemporaryPassword(): boolean; set usesTemporaryPassword(value: boolean); private __fetch; }