pratik-auth-sdk-test
Version:
Arvasit Authentication SDK for Node.js
176 lines (175 loc) • 9.04 kB
TypeScript
import { CheckCredentialRequest, CheckCredentialResponse, CheckUserNameRequest, CredentialForForgotPasswordRequest, DisableTwoFARequest, EnterCredentialForForgotPasswordResponse, ForgotPasswordSendOTPRequest, GenerateQRCodeAndSecretFor2FARequest, GenerateQrCodeAndSecretFor2FAResponse, GenerateRecoveryCodesRequest, ListOfRecoveryCodeRequest, ListOfRecoveryCodeResponse, ListOfSecretKeysRequest, ListOfSecretKeysResponse, LoginActivityCountResponse, LoginActivityCountsRequest, LoginActivityDetailsRequest, LoginActivityDetailsResponse, LoginRequest, LoginResponse, LogoutRequest, OtpLoginRequest, RecoveryCodeLoginRequest, RefreshAccessTokenRequest, RefreshTokenResponse, RemoveTwoFADeviceRequest, SignupRequest, SignupResponse, SuggestUsernameRequest, TwoFALoginRequest, UpdatePasswordRequest, ValidateForgetPasswordTokenRequest, VerifyForgotPasswordOTPRequest, VerifyQRCodeAndSecretFor2FARequest, VerifyTokenSetupPasswordRequest } from './auth-types';
export interface AuthServiceConfig {
url: string;
publicKey: string;
secretKey: string;
}
export declare class AuthService {
private client;
private config;
constructor(config: AuthServiceConfig);
/**
* Generates headers for authentication requests.
* @param path - The endpoint path to include in signature data.
* @returns Authentication headers.
*/
private getAuthHeaders;
/**
* Signup.
* @param params - The params is used for sign in.
* @returns A promise that resolves to the create a user.
*/
signup(params: SignupRequest): Promise<SignupResponse>;
/**
* Suggest username which is not present in the system.
* @param params - An Object of firstName and lastName.
* @returns A promise that resolves to give available username.
*/
suggestUsername(params: SuggestUsernameRequest): Promise<string[]>;
/**
* check available username which is not present in the system.
* @param params - An Object of username.
* @returns A promise that resolves to boolean.
*/
checkAvailableUserName(params: CheckUserNameRequest): Promise<boolean>;
/**
* Check the type of credential (e.g., email or phone).
* @param credential - The credential to check.
* @returns A promise that resolves to the credential check result.
*/
checkCredential({ credential }: CheckCredentialRequest): Promise<CheckCredentialResponse>;
/**
* Login using a password.
* @param params - An object containing credential and password.
* @returns A promise that resolves to the login response.
*/
loginWithPassword(params: LoginRequest): Promise<LoginResponse>;
/**
* Login using an OTP (One-Time Password).
* @param params - An object containing credential and OTP.
* @returns A promise that resolves to the login response.
*/
loginWithOtp(params: OtpLoginRequest): Promise<LoginResponse>;
/**
* Send an OTP (One-Time Password) for login.
* @param params - An object containing credential.
* @returns A promise that resolves to send OTP on credential.
*/
sendOtpForLogin({ credential }: CheckCredentialRequest): Promise<CheckCredentialResponse>;
/**
* Login using two factor authentication.
* @param params - An object containing credential and OTP.
* @returns A promise that resolves to the login response.
*/
verifyTwoFactorAuthenticationToLogin(params: TwoFALoginRequest): Promise<LoginResponse>;
/**
* Login using recovery code.
* @param params - An object containing credential and OTP.
* @returns A promise that resolves to the login response.
*/
loginWithRecoveryCode(params: RecoveryCodeLoginRequest): Promise<LoginResponse>;
/**
* logout is to remove session of user.
* @param params - An object containing of access token.
* @returns A promise that resolves to boolean.
*/
logout(params: LogoutRequest): Promise<string>;
/**
* Enter credential for forgot password to get type email or phone to send otp on.
* @param Credential - The credential for forgot password.
* @returns A promise that resolves to send otp type with masked email and phone.
*/
enterCredentialForForgotPassword({ credential, }: CredentialForForgotPasswordRequest): Promise<EnterCredentialForForgotPasswordResponse>;
/**
* Send otp on credential for forgot password authorization.
* @param params - An object containing credential and OTP.
* @returns A promise that resolves to give token to set new password.
*/
forgotPasswordSendOTP(params: ForgotPasswordSendOTPRequest): Promise<string>;
/**
* Verify otp for forget password reset.
* @param params - An object containing credential and OTP.
* @returns A promise that resolves to give token to set new password.
*/
verifyForgotPasswordOtp(params: VerifyForgotPasswordOTPRequest): Promise<string>;
/**
* Check forgot password generated token is valid for setting up new password.
* @param token - An object containing token and password.
* @returns A promise that resolves to true.
*/
validateForgetPasswordToken(params: ValidateForgetPasswordTokenRequest): Promise<boolean>;
/**
* Check forgot password generated token is valid and set new password.
* @param params - Token generated after verifying forgot password otp.
* @returns A promise that resolves to token is valid or not.
*/
verifyTokenSetupPassword(params: VerifyTokenSetupPasswordRequest): Promise<boolean>;
/**
* Update.
* @param params - An object containing credential and OTP.
* @returns A promise that resolves to give true.
*/
updatePassword(params: UpdatePasswordRequest): Promise<boolean>;
/**
* Send otp on credential for forgot password authorization.
* @param params - An object containing accessToken.
* @returns A promise that resolves to give token to set new password.
*/
generateRecoveryCodes(params: GenerateRecoveryCodesRequest): Promise<LoginResponse>;
/**
* Send refresh access token to get new access token for authorization.
* @param params - An object containing of access token.
* @returns A promise that resolves to give new access token for api authorization.
*/
refreshAccessToken(params: RefreshAccessTokenRequest): Promise<RefreshTokenResponse>;
/**
* Generate qr code and secret to set up two factor authentication.
* @param params - An object containing of access token.
* @returns A promise that resolves to give QR Code Image and Secret key.
*/
generateQRCodeAndSecretFor2FA(params: GenerateQRCodeAndSecretFor2FARequest): Promise<GenerateQrCodeAndSecretFor2FAResponse>;
/**
* Verify generated qr code and secret to add two factor authentication.
* @param params - An object containing of access token, totp and secret key.
* @returns A promise that resolves to give QR Code Image and Secret key.
*/
verifyQRCodeAndSecretFor2FA(params: VerifyQRCodeAndSecretFor2FARequest): Promise<GenerateQrCodeAndSecretFor2FAResponse>;
/**
* List of two factor authentication secret of logged in user.
* @param params - An object containing of access token.
* @returns A promise that resolves to give array of 2FA secret keys.
*/
listOfTwoFASecrets(params: ListOfSecretKeysRequest): Promise<ListOfSecretKeysResponse>;
/**
* Remove two factor authentication device of logged in user.
* @param params - An object containing of access token and key i.e secret key.
* @returns A promise that resolves to give array of 2FA secret keys.
*/
removeTwoFADevice(params: RemoveTwoFADeviceRequest): Promise<string[]>;
/**
* Disable two factor authentication of logged in user.
* @param params - An object containing of access token.
* @returns A promise that resolves to give array of 2FA secret keys.
*/
disableTwoFA(params: DisableTwoFARequest): Promise<boolean>;
/**
* List of recovery code or security code of logged in user.
* @param params - An object containing of access token.
* @returns A promise that resolves to give array of 2FA secret keys.
*/
listOfRecoveryCode(params: ListOfRecoveryCodeRequest): Promise<ListOfRecoveryCodeResponse>;
/**
* Get login activity counts.
* @param params - An object containing of pagination.
* @returns A promise that resolves to give new access token for api authorization.
*/
loginActivityCounts(params: LoginActivityCountsRequest): Promise<LoginActivityCountResponse>;
/**
* Get login activity details.
* @param params - An object containing of pagination.
* @returns A promise that resolves to give new access token for api authorization.
*/
loginActivityDetails(params: LoginActivityDetailsRequest): Promise<LoginActivityDetailsResponse>;
private handleError;
}
export default AuthService;