import * as plugins from '../plugins.js'; import * as data from '../data/index.js'; export interface IReq_LoginWithEmailOrUsernameAndPassword extends plugins.typedRequestInterfaces.implementsTR { method: 'loginWithEmailOrUsernameAndPassword'; request: { username: string; password: string; }; response: { refreshToken?: string; twoFaNeeded: boolean; mfaChallengeToken?: string; availableMfaMethods?: data.TMfaMethod[]; }; } export interface IReq_LoginWithEmail extends plugins.typedRequestInterfaces.implementsTR { method: 'loginWithEmail'; request: { email: string; }; response: { status: 'ok' | 'not ok'; testOnlyToken?: string; }; } export interface IReq_LoginWithEmailAfterEmailTokenAquired extends plugins.typedRequestInterfaces.implementsTR { method: 'loginWithEmailAfterEmailTokenAquired'; request: { email: string; token: string; }; response: { refreshToken?: string; twoFaNeeded?: boolean; mfaChallengeToken?: string; availableMfaMethods?: data.TMfaMethod[]; }; } export interface IReq_LoginWithEmailCode extends plugins.typedRequestInterfaces.implementsTR { method: 'loginWithEmailCode'; request: { email: string; /** * the 6-digit code delivered in the sign-in email alongside the link */ code: string; }; response: { refreshToken?: string; twoFaNeeded?: boolean; mfaChallengeToken?: string; availableMfaMethods?: data.TMfaMethod[]; }; } export interface ILogoutRequest extends plugins.typedRequestInterfaces.implementsTR { method: 'logout'; request: { refreshToken: string; }; response: {}; } export interface IReq_RefreshJwt extends plugins.typedRequestInterfaces.implementsTR { method: 'refreshJwt'; request: { refreshToken: string; }; response: { status: data.TLoginStatus; jwt?: string; refreshToken?: string; }; } /** * allows the exchange between refreshToken and transferTokens */ export interface IReq_ExchangeRefreshTokenAndTransferToken extends plugins.typedRequestInterfaces.implementsTR { method: 'exchangeRefreshTokenAndTransferToken'; request: { transferToken?: string; refreshToken?: string; transferTarget: data.ITransferTarget; }; response: { refreshToken?: string; transferToken?: string; }; } /** * Starts password recovery without revealing whether the account exists. */ export interface IReq_ResetPassword extends plugins.typedRequestInterfaces.implementsTR { method: 'resetPassword'; request: { email: string; }; response: { status: 'ok' | 'not ok'; }; } /** * Completes an authenticated password change or recovery-token reset. */ export type TSetNewPasswordRequest = { email: string; jwt: string; oldPassword: string; tokenArg?: never; newPassword: string; } | { email: string; jwt?: never; oldPassword?: never; tokenArg: string; newPassword: string; }; export interface IReq_SetNewPassword extends plugins.typedRequestInterfaces.implementsTR { method: 'setNewPassword'; request: TSetNewPasswordRequest; response: { status: 'ok' | 'not ok'; }; } export interface IReq_ObtainDeviceId extends plugins.typedRequestInterfaces.implementsTR { method: 'obtainDeviceId'; request: {}; response: { deviceId: data.IDevice; }; } /** * allows attaching a device id to a login session * to share a login session across contexts */ export interface IReq_AttachDeviceId extends plugins.typedRequestInterfaces.implementsTR { method: 'attachDeviceId'; request: { jwt: string; deviceId: string; }; response: { ok: boolean; }; }