Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@genezio/auth

Package Overview
Dependencies
Maintainers
4
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@genezio/auth - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

91

dist/cjs/authService.sdk.d.ts

@@ -6,3 +6,3 @@ /**

import { Remote } from "./remote";
import { UserLoginResponse, ResetPasswordResponse, ResetPasswordConfirmResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse } from "./models/UserTypes";
import { UserLoginResponse, ResetPasswordResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse, ResetPasswordConfirmResponse, UserInfoResponse } from "./models/UserTypes";
export interface Storage {

@@ -26,14 +26,95 @@ setItem(key: string, value: string): void;

export declare class AuthService {
remote: Remote;
constructor(token: string, region: string);
private static notInitializedErrorMessage;
private static instance;
private remote;
/**
* @method getInstance
* @description Method that returns an instance of the AuthService class. This method should be used instead of the constructor.
* @returns {AuthService} An instance of the AuthService class.
*/
static getInstance(): AuthService;
/**
* @method setTokenAndRegion
* @description Method that should be called before any other method. This method sets the token and region
* that will be used to call the remote functions.
* @param {string} token - The token provided in genezio dashboard.
* @param {string} region - The region provided in genezio dashboard.
* @returns {void}
* @example
* AuthService.getInstance().setTokenAndRegion("0-1234567890", "us-east-1")
*/
setTokenAndRegion(token: string, region: string): void;
/**
* @method register
* @description Method that can be used to create a new user.
*
* @param {string} email The user's email.
* @param {string} password The user's password.
* @param {string} name The user's name. Optional.
*
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the creation was successful, false otherwise.
*/
register(email: string, password: string, name?: string): Promise<UserLoginResponse>;
/**
* @method login
* @description Method that can be used to obtain a login token for a giving user.
*
* @param {string} email The user's email.
* @param {string} password The user's password.
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the login was successful, false otherwise.
*/
login(email: string, password: string): Promise<UserLoginResponse>;
/**
* @method resetPassword
* @description Sends a password reset token to a user's email.
* @param {string} email - The user's email address.
* @returns {Promise<ResetPasswordResponse>} An object with a boolean property "success" indicating success.
*/
resetPassword(email: string): Promise<ResetPasswordResponse>;
resetPasswordConfirmation(token: string, password: string): Promise<ResetPasswordConfirmResponse>;
/**
* @method emailConfirmation
* @description Confirms the user's email address. This method should be called after the user clicks on the link
* received in the email.
* @param {string} token - The token received in the email.
*
* @returns {Promise<EmailConfirmationResponse>} An object with a boolean property "success" indicating success or failure.
*/
emailConfirmation(token: string): Promise<EmailConfirmationResponse>;
/**
* @method resendEmailConfirmation
* @description Resends the email confirmation email to the user.
* @param {string} email
* @returns {Promise<ResendEmailConfirmationResponse>} An object with a boolean property "success" indicating success or failure.
*/
resendEmailConfirmation(email: string): Promise<ResendEmailConfirmationResponse>;
/**
* @method resetPasswordConfirmation
* @description Confirms the user's new password. This method should be called after the user clicks on the link
* received in the email.
* @param {string} token - The token received in the email.
* @param {string} password - The new password.
* @returns {Promise<ResetPasswordConfirmResponse>} An object with a boolean property "success" indicating success or failure.
*/
resetPasswordConfirmation(token: string, password: string): Promise<ResetPasswordConfirmResponse>;
/**
* @method googleRegistration
* @description Method that can be used to obtain a login token for a giving user.
*
* @param {string} googleToken The user's Google token.
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the login was successful, false otherwise.
*/
googleRegistration(googleToken: string): Promise<UserLoginResponse>;
userInfo(token: string): Promise<UserLoginResponse>;
/**
* @method userInfo
* @description Method that can be used to obtain information about the user.
* @param {string} token The user's token. If not provided, the token stored in the local storage will be used.
* @returns {Promise<UserInfoResponse>} An object containing a boolean property "success" which is true if the
* token is valid, false otherwise.
*/
userInfo(token: string | undefined): Promise<UserInfoResponse>;
logout(): Promise<void>;
}
export { Remote };

@@ -39,3 +39,27 @@ "use strict";

class AuthService {
constructor(token, region) {
constructor() {
this.remote = null;
}
/**
* @method getInstance
* @description Method that returns an instance of the AuthService class. This method should be used instead of the constructor.
* @returns {AuthService} An instance of the AuthService class.
*/
static getInstance() {
if (!this.instance) {
this.instance = new AuthService();
}
return this.instance;
}
/**
* @method setTokenAndRegion
* @description Method that should be called before any other method. This method sets the token and region
* that will be used to call the remote functions.
* @param {string} token - The token provided in genezio dashboard.
* @param {string} region - The region provided in genezio dashboard.
* @returns {void}
* @example
* AuthService.getInstance().setTokenAndRegion("0-1234567890", "us-east-1")
*/
setTokenAndRegion(token, region) {
const [cloud, id] = token.split("-");

@@ -54,25 +78,103 @@ let url;

}
/**
* @method register
* @description Method that can be used to create a new user.
*
* @param {string} email The user's email.
* @param {string} password The user's password.
* @param {string} name The user's name. Optional.
*
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the creation was successful, false otherwise.
*/
async register(email, password, name) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.register", email, password, name);
}
/**
* @method login
* @description Method that can be used to obtain a login token for a giving user.
*
* @param {string} email The user's email.
* @param {string} password The user's password.
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the login was successful, false otherwise.
*/
async login(email, password) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
const response = await this.remote.call("AuthService.login", email, password);
if (response === "ok") {
if (response.success === true) {
StorageManager.getStorage().setItem("token", response.token);
console.log("de aici", StorageManager.getStorage().getItem("token"));
}
return response;
}
/**
* @method resetPassword
* @description Sends a password reset token to a user's email.
* @param {string} email - The user's email address.
* @returns {Promise<ResetPasswordResponse>} An object with a boolean property "success" indicating success.
*/
async resetPassword(email) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.resetPassword", email);
}
async resetPasswordConfirmation(token, password) {
return await this.remote.call("AuthService.resetPasswordConfirmation", token, password);
}
/**
* @method emailConfirmation
* @description Confirms the user's email address. This method should be called after the user clicks on the link
* received in the email.
* @param {string} token - The token received in the email.
*
* @returns {Promise<EmailConfirmationResponse>} An object with a boolean property "success" indicating success or failure.
*/
async emailConfirmation(token) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.emailConfirmation", token);
}
/**
* @method resendEmailConfirmation
* @description Resends the email confirmation email to the user.
* @param {string} email
* @returns {Promise<ResendEmailConfirmationResponse>} An object with a boolean property "success" indicating success or failure.
*/
async resendEmailConfirmation(email) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.resendEmailConfirmation", email);
}
/**
* @method resetPasswordConfirmation
* @description Confirms the user's new password. This method should be called after the user clicks on the link
* received in the email.
* @param {string} token - The token received in the email.
* @param {string} password - The new password.
* @returns {Promise<ResetPasswordConfirmResponse>} An object with a boolean property "success" indicating success or failure.
*/
async resetPasswordConfirmation(token, password) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.resetPasswordConfirmation", token, password);
}
/**
* @method googleRegistration
* @description Method that can be used to obtain a login token for a giving user.
*
* @param {string} googleToken The user's Google token.
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the login was successful, false otherwise.
*/
async googleRegistration(googleToken) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
const response = await this.remote.call("AuthService.registrationFinished", googleToken);

@@ -84,4 +186,19 @@ if (response === "ok") {

}
/**
* @method userInfo
* @description Method that can be used to obtain information about the user.
* @param {string} token The user's token. If not provided, the token stored in the local storage will be used.
* @returns {Promise<UserInfoResponse>} An object containing a boolean property "success" which is true if the
* token is valid, false otherwise.
*/
async userInfo(token) {
return await this.remote.call("AuthService.userInfo", token);
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
if (!token) {
return await this.remote.call("AuthService.userInfo", StorageManager.getStorage().getItem("token"));
}
else {
return await this.remote.call("AuthService.userInfo", token);
}
}

@@ -93,1 +210,3 @@ async logout() {

exports.AuthService = AuthService;
AuthService.notInitializedErrorMessage = "The AuthService class was not initialized. Call AuthService.getInstance().setTokenAndRegion(token, region) with the values provided in genezio dashboard. Check <link> for more information.";
AuthService.instance = null;

10

dist/cjs/index.d.ts
/**
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
import { AuthService } from "./authService.sdk";
import { User, UserLoginResponse, ResetPasswordResponse, ResetPasswordConfirmResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse } from "./models/UserTypes";
export { AuthService, User, UserLoginResponse, ResetPasswordResponse, ResetPasswordConfirmResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse };
import { User, ErrorCode, ErrorResponse, UserLoginResponse, ResetPasswordResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse, ResetPasswordConfirmResponse, UserInfoResponse } from "./models/UserTypes";
export { AuthService, User, ErrorCode, ErrorResponse, UserLoginResponse, ResetPasswordResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse, ResetPasswordConfirmResponse, UserInfoResponse };
"use strict";
/**
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthService = void 0;
exports.ErrorCode = exports.AuthService = void 0;
const authService_sdk_1 = require("./authService.sdk");
Object.defineProperty(exports, "AuthService", { enumerable: true, get: function () { return authService_sdk_1.AuthService; } });
const UserTypes_1 = require("./models/UserTypes");
Object.defineProperty(exports, "ErrorCode", { enumerable: true, get: function () { return UserTypes_1.ErrorCode; } });
/**
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
export type User = {

@@ -15,2 +15,28 @@ email: string;

};
export declare enum ErrorCode {
CONNECTION_DATABASE_ERROR = 0,
MISSING_EMAIL_PARAMETER = 1,
INCORRECT_EMAIL_OR_PASSWORD = 2,
EMAIL_ALREADY_EXISTS = 3,
EMAIL_NOT_FOUND = 4,
INVALID_TOKEN = 5,
MISSING_PASSWORD_PARAMETER = 6,
PASSWORD_TOO_SHORT = 7,
PASSWORD_CONTAINS_ONLY_NUMBER = 8,
PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER = 9,
INTERNAL_PASSWORD_NOT_HASHED_ERROR = 10,
INTERNAL_CREATE_USER_ERROR = 11,
INTERNAL_CREATE_SESSION_ERROR = 12,
INTERNAL_UPDATE_USER_ERROR = 13,
INTERNAL_UPDATE_SESSION_ERROR = 14,
INTERNAL_DELETE_SESSION_ERROR = 15,
INTERNAL_DELETE_USER_ERROR = 16,
INTERNAL_FIND_USER_ERROR = 17,
INTERNAL_FIND_SESSION_ERROR = 18,
MAIL_NOT_SENT = 19
}
export type ErrorResponse = {
code: ErrorCode;
message: string;
};
export type UserLoginResponse = {

@@ -20,26 +46,26 @@ success: boolean;

token?: string;
errorMessage?: string;
error?: ErrorResponse;
};
export type UserInfoResponse = {
success: boolean;
user?: User;
errorMessage?: string;
};
export type ResetPasswordResponse = {
success: boolean;
errorMessage?: string;
error?: ErrorResponse;
};
export type ResetPasswordConfirmResponse = {
export type EmailConfirmationResponse = {
success: boolean;
user?: User;
errorMessage?: string;
error?: ErrorResponse;
};
export type ResendEmailConfirmationResponse = {
success: boolean;
errorMessage?: string;
error?: ErrorResponse;
};
export type EmailConfirmationResponse = {
export type ResetPasswordConfirmResponse = {
success: boolean;
user?: User;
errorMessage?: string;
error?: ErrorResponse;
};
export type UserInfoResponse = {
success: boolean;
user?: User;
error?: ErrorResponse;
};
"use strict";
/**
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorCode = void 0;
var ErrorCode;
(function (ErrorCode) {
ErrorCode[ErrorCode["CONNECTION_DATABASE_ERROR"] = 0] = "CONNECTION_DATABASE_ERROR";
ErrorCode[ErrorCode["MISSING_EMAIL_PARAMETER"] = 1] = "MISSING_EMAIL_PARAMETER";
ErrorCode[ErrorCode["INCORRECT_EMAIL_OR_PASSWORD"] = 2] = "INCORRECT_EMAIL_OR_PASSWORD";
ErrorCode[ErrorCode["EMAIL_ALREADY_EXISTS"] = 3] = "EMAIL_ALREADY_EXISTS";
ErrorCode[ErrorCode["EMAIL_NOT_FOUND"] = 4] = "EMAIL_NOT_FOUND";
ErrorCode[ErrorCode["INVALID_TOKEN"] = 5] = "INVALID_TOKEN";
ErrorCode[ErrorCode["MISSING_PASSWORD_PARAMETER"] = 6] = "MISSING_PASSWORD_PARAMETER";
ErrorCode[ErrorCode["PASSWORD_TOO_SHORT"] = 7] = "PASSWORD_TOO_SHORT";
ErrorCode[ErrorCode["PASSWORD_CONTAINS_ONLY_NUMBER"] = 8] = "PASSWORD_CONTAINS_ONLY_NUMBER";
ErrorCode[ErrorCode["PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER"] = 9] = "PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER";
ErrorCode[ErrorCode["INTERNAL_PASSWORD_NOT_HASHED_ERROR"] = 10] = "INTERNAL_PASSWORD_NOT_HASHED_ERROR";
ErrorCode[ErrorCode["INTERNAL_CREATE_USER_ERROR"] = 11] = "INTERNAL_CREATE_USER_ERROR";
ErrorCode[ErrorCode["INTERNAL_CREATE_SESSION_ERROR"] = 12] = "INTERNAL_CREATE_SESSION_ERROR";
ErrorCode[ErrorCode["INTERNAL_UPDATE_USER_ERROR"] = 13] = "INTERNAL_UPDATE_USER_ERROR";
ErrorCode[ErrorCode["INTERNAL_UPDATE_SESSION_ERROR"] = 14] = "INTERNAL_UPDATE_SESSION_ERROR";
ErrorCode[ErrorCode["INTERNAL_DELETE_SESSION_ERROR"] = 15] = "INTERNAL_DELETE_SESSION_ERROR";
ErrorCode[ErrorCode["INTERNAL_DELETE_USER_ERROR"] = 16] = "INTERNAL_DELETE_USER_ERROR";
ErrorCode[ErrorCode["INTERNAL_FIND_USER_ERROR"] = 17] = "INTERNAL_FIND_USER_ERROR";
ErrorCode[ErrorCode["INTERNAL_FIND_SESSION_ERROR"] = 18] = "INTERNAL_FIND_SESSION_ERROR";
ErrorCode[ErrorCode["MAIL_NOT_SENT"] = 19] = "MAIL_NOT_SENT";
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));

@@ -6,3 +6,3 @@ /**

import { Remote } from "./remote";
import { UserLoginResponse, ResetPasswordResponse, ResetPasswordConfirmResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse } from "./models/UserTypes";
import { UserLoginResponse, ResetPasswordResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse, ResetPasswordConfirmResponse, UserInfoResponse } from "./models/UserTypes";
export interface Storage {

@@ -26,14 +26,95 @@ setItem(key: string, value: string): void;

export declare class AuthService {
remote: Remote;
constructor(token: string, region: string);
private static notInitializedErrorMessage;
private static instance;
private remote;
/**
* @method getInstance
* @description Method that returns an instance of the AuthService class. This method should be used instead of the constructor.
* @returns {AuthService} An instance of the AuthService class.
*/
static getInstance(): AuthService;
/**
* @method setTokenAndRegion
* @description Method that should be called before any other method. This method sets the token and region
* that will be used to call the remote functions.
* @param {string} token - The token provided in genezio dashboard.
* @param {string} region - The region provided in genezio dashboard.
* @returns {void}
* @example
* AuthService.getInstance().setTokenAndRegion("0-1234567890", "us-east-1")
*/
setTokenAndRegion(token: string, region: string): void;
/**
* @method register
* @description Method that can be used to create a new user.
*
* @param {string} email The user's email.
* @param {string} password The user's password.
* @param {string} name The user's name. Optional.
*
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the creation was successful, false otherwise.
*/
register(email: string, password: string, name?: string): Promise<UserLoginResponse>;
/**
* @method login
* @description Method that can be used to obtain a login token for a giving user.
*
* @param {string} email The user's email.
* @param {string} password The user's password.
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the login was successful, false otherwise.
*/
login(email: string, password: string): Promise<UserLoginResponse>;
/**
* @method resetPassword
* @description Sends a password reset token to a user's email.
* @param {string} email - The user's email address.
* @returns {Promise<ResetPasswordResponse>} An object with a boolean property "success" indicating success.
*/
resetPassword(email: string): Promise<ResetPasswordResponse>;
resetPasswordConfirmation(token: string, password: string): Promise<ResetPasswordConfirmResponse>;
/**
* @method emailConfirmation
* @description Confirms the user's email address. This method should be called after the user clicks on the link
* received in the email.
* @param {string} token - The token received in the email.
*
* @returns {Promise<EmailConfirmationResponse>} An object with a boolean property "success" indicating success or failure.
*/
emailConfirmation(token: string): Promise<EmailConfirmationResponse>;
/**
* @method resendEmailConfirmation
* @description Resends the email confirmation email to the user.
* @param {string} email
* @returns {Promise<ResendEmailConfirmationResponse>} An object with a boolean property "success" indicating success or failure.
*/
resendEmailConfirmation(email: string): Promise<ResendEmailConfirmationResponse>;
/**
* @method resetPasswordConfirmation
* @description Confirms the user's new password. This method should be called after the user clicks on the link
* received in the email.
* @param {string} token - The token received in the email.
* @param {string} password - The new password.
* @returns {Promise<ResetPasswordConfirmResponse>} An object with a boolean property "success" indicating success or failure.
*/
resetPasswordConfirmation(token: string, password: string): Promise<ResetPasswordConfirmResponse>;
/**
* @method googleRegistration
* @description Method that can be used to obtain a login token for a giving user.
*
* @param {string} googleToken The user's Google token.
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the login was successful, false otherwise.
*/
googleRegistration(googleToken: string): Promise<UserLoginResponse>;
userInfo(token: string): Promise<UserLoginResponse>;
/**
* @method userInfo
* @description Method that can be used to obtain information about the user.
* @param {string} token The user's token. If not provided, the token stored in the local storage will be used.
* @returns {Promise<UserInfoResponse>} An object containing a boolean property "success" which is true if the
* token is valid, false otherwise.
*/
userInfo(token: string | undefined): Promise<UserInfoResponse>;
logout(): Promise<void>;
}
export { Remote };

@@ -33,3 +33,27 @@ /**

export class AuthService {
constructor(token, region) {
constructor() {
this.remote = null;
}
/**
* @method getInstance
* @description Method that returns an instance of the AuthService class. This method should be used instead of the constructor.
* @returns {AuthService} An instance of the AuthService class.
*/
static getInstance() {
if (!this.instance) {
this.instance = new AuthService();
}
return this.instance;
}
/**
* @method setTokenAndRegion
* @description Method that should be called before any other method. This method sets the token and region
* that will be used to call the remote functions.
* @param {string} token - The token provided in genezio dashboard.
* @param {string} region - The region provided in genezio dashboard.
* @returns {void}
* @example
* AuthService.getInstance().setTokenAndRegion("0-1234567890", "us-east-1")
*/
setTokenAndRegion(token, region) {
const [cloud, id] = token.split("-");

@@ -48,25 +72,103 @@ let url;

}
/**
* @method register
* @description Method that can be used to create a new user.
*
* @param {string} email The user's email.
* @param {string} password The user's password.
* @param {string} name The user's name. Optional.
*
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the creation was successful, false otherwise.
*/
async register(email, password, name) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.register", email, password, name);
}
/**
* @method login
* @description Method that can be used to obtain a login token for a giving user.
*
* @param {string} email The user's email.
* @param {string} password The user's password.
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the login was successful, false otherwise.
*/
async login(email, password) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
const response = await this.remote.call("AuthService.login", email, password);
if (response === "ok") {
if (response.success === true) {
StorageManager.getStorage().setItem("token", response.token);
console.log("de aici", StorageManager.getStorage().getItem("token"));
}
return response;
}
/**
* @method resetPassword
* @description Sends a password reset token to a user's email.
* @param {string} email - The user's email address.
* @returns {Promise<ResetPasswordResponse>} An object with a boolean property "success" indicating success.
*/
async resetPassword(email) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.resetPassword", email);
}
async resetPasswordConfirmation(token, password) {
return await this.remote.call("AuthService.resetPasswordConfirmation", token, password);
}
/**
* @method emailConfirmation
* @description Confirms the user's email address. This method should be called after the user clicks on the link
* received in the email.
* @param {string} token - The token received in the email.
*
* @returns {Promise<EmailConfirmationResponse>} An object with a boolean property "success" indicating success or failure.
*/
async emailConfirmation(token) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.emailConfirmation", token);
}
/**
* @method resendEmailConfirmation
* @description Resends the email confirmation email to the user.
* @param {string} email
* @returns {Promise<ResendEmailConfirmationResponse>} An object with a boolean property "success" indicating success or failure.
*/
async resendEmailConfirmation(email) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.resendEmailConfirmation", email);
}
/**
* @method resetPasswordConfirmation
* @description Confirms the user's new password. This method should be called after the user clicks on the link
* received in the email.
* @param {string} token - The token received in the email.
* @param {string} password - The new password.
* @returns {Promise<ResetPasswordConfirmResponse>} An object with a boolean property "success" indicating success or failure.
*/
async resetPasswordConfirmation(token, password) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.resetPasswordConfirmation", token, password);
}
/**
* @method googleRegistration
* @description Method that can be used to obtain a login token for a giving user.
*
* @param {string} googleToken The user's Google token.
* @returns {Promise<UserLoginResponse>} An object containing a boolean property "success" which
* is true if the login was successful, false otherwise.
*/
async googleRegistration(googleToken) {
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
const response = await this.remote.call("AuthService.registrationFinished", googleToken);

@@ -78,4 +180,19 @@ if (response === "ok") {

}
/**
* @method userInfo
* @description Method that can be used to obtain information about the user.
* @param {string} token The user's token. If not provided, the token stored in the local storage will be used.
* @returns {Promise<UserInfoResponse>} An object containing a boolean property "success" which is true if the
* token is valid, false otherwise.
*/
async userInfo(token) {
return await this.remote.call("AuthService.userInfo", token);
if (!this.remote) {
throw new Error(AuthService.notInitializedErrorMessage);
}
if (!token) {
return await this.remote.call("AuthService.userInfo", StorageManager.getStorage().getItem("token"));
}
else {
return await this.remote.call("AuthService.userInfo", token);
}
}

@@ -86,2 +203,4 @@ async logout() {

}
AuthService.notInitializedErrorMessage = "The AuthService class was not initialized. Call AuthService.getInstance().setTokenAndRegion(token, region) with the values provided in genezio dashboard. Check <link> for more information.";
AuthService.instance = null;
export { Remote };
/**
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
import { AuthService } from "./authService.sdk";
import { User, UserLoginResponse, ResetPasswordResponse, ResetPasswordConfirmResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse } from "./models/UserTypes";
export { AuthService, User, UserLoginResponse, ResetPasswordResponse, ResetPasswordConfirmResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse };
import { User, ErrorCode, ErrorResponse, UserLoginResponse, ResetPasswordResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse, ResetPasswordConfirmResponse, UserInfoResponse } from "./models/UserTypes";
export { AuthService, User, ErrorCode, ErrorResponse, UserLoginResponse, ResetPasswordResponse, EmailConfirmationResponse, ResendEmailConfirmationResponse, ResetPasswordConfirmResponse, UserInfoResponse };
/**
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
import { AuthService } from "./authService.sdk";
export { AuthService };
import { ErrorCode } from "./models/UserTypes";
export { AuthService, ErrorCode };
/**
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
export type User = {

@@ -15,2 +15,28 @@ email: string;

};
export declare enum ErrorCode {
CONNECTION_DATABASE_ERROR = 0,
MISSING_EMAIL_PARAMETER = 1,
INCORRECT_EMAIL_OR_PASSWORD = 2,
EMAIL_ALREADY_EXISTS = 3,
EMAIL_NOT_FOUND = 4,
INVALID_TOKEN = 5,
MISSING_PASSWORD_PARAMETER = 6,
PASSWORD_TOO_SHORT = 7,
PASSWORD_CONTAINS_ONLY_NUMBER = 8,
PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER = 9,
INTERNAL_PASSWORD_NOT_HASHED_ERROR = 10,
INTERNAL_CREATE_USER_ERROR = 11,
INTERNAL_CREATE_SESSION_ERROR = 12,
INTERNAL_UPDATE_USER_ERROR = 13,
INTERNAL_UPDATE_SESSION_ERROR = 14,
INTERNAL_DELETE_SESSION_ERROR = 15,
INTERNAL_DELETE_USER_ERROR = 16,
INTERNAL_FIND_USER_ERROR = 17,
INTERNAL_FIND_SESSION_ERROR = 18,
MAIL_NOT_SENT = 19
}
export type ErrorResponse = {
code: ErrorCode;
message: string;
};
export type UserLoginResponse = {

@@ -20,26 +46,26 @@ success: boolean;

token?: string;
errorMessage?: string;
error?: ErrorResponse;
};
export type UserInfoResponse = {
success: boolean;
user?: User;
errorMessage?: string;
};
export type ResetPasswordResponse = {
success: boolean;
errorMessage?: string;
error?: ErrorResponse;
};
export type ResetPasswordConfirmResponse = {
export type EmailConfirmationResponse = {
success: boolean;
user?: User;
errorMessage?: string;
error?: ErrorResponse;
};
export type ResendEmailConfirmationResponse = {
success: boolean;
errorMessage?: string;
error?: ErrorResponse;
};
export type EmailConfirmationResponse = {
export type ResetPasswordConfirmResponse = {
success: boolean;
user?: User;
errorMessage?: string;
error?: ErrorResponse;
};
export type UserInfoResponse = {
success: boolean;
user?: User;
error?: ErrorResponse;
};
/**
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
export {};
* This is an auto generated code. This code should not be modified since the file can be overwritten
* if new genezio commands are executed.
*/
export var ErrorCode;
(function (ErrorCode) {
ErrorCode[ErrorCode["CONNECTION_DATABASE_ERROR"] = 0] = "CONNECTION_DATABASE_ERROR";
ErrorCode[ErrorCode["MISSING_EMAIL_PARAMETER"] = 1] = "MISSING_EMAIL_PARAMETER";
ErrorCode[ErrorCode["INCORRECT_EMAIL_OR_PASSWORD"] = 2] = "INCORRECT_EMAIL_OR_PASSWORD";
ErrorCode[ErrorCode["EMAIL_ALREADY_EXISTS"] = 3] = "EMAIL_ALREADY_EXISTS";
ErrorCode[ErrorCode["EMAIL_NOT_FOUND"] = 4] = "EMAIL_NOT_FOUND";
ErrorCode[ErrorCode["INVALID_TOKEN"] = 5] = "INVALID_TOKEN";
ErrorCode[ErrorCode["MISSING_PASSWORD_PARAMETER"] = 6] = "MISSING_PASSWORD_PARAMETER";
ErrorCode[ErrorCode["PASSWORD_TOO_SHORT"] = 7] = "PASSWORD_TOO_SHORT";
ErrorCode[ErrorCode["PASSWORD_CONTAINS_ONLY_NUMBER"] = 8] = "PASSWORD_CONTAINS_ONLY_NUMBER";
ErrorCode[ErrorCode["PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER"] = 9] = "PASSWORD_MUST_HAVE_AT_LEAST_ONE_SPECIAL_CHARACTER";
ErrorCode[ErrorCode["INTERNAL_PASSWORD_NOT_HASHED_ERROR"] = 10] = "INTERNAL_PASSWORD_NOT_HASHED_ERROR";
ErrorCode[ErrorCode["INTERNAL_CREATE_USER_ERROR"] = 11] = "INTERNAL_CREATE_USER_ERROR";
ErrorCode[ErrorCode["INTERNAL_CREATE_SESSION_ERROR"] = 12] = "INTERNAL_CREATE_SESSION_ERROR";
ErrorCode[ErrorCode["INTERNAL_UPDATE_USER_ERROR"] = 13] = "INTERNAL_UPDATE_USER_ERROR";
ErrorCode[ErrorCode["INTERNAL_UPDATE_SESSION_ERROR"] = 14] = "INTERNAL_UPDATE_SESSION_ERROR";
ErrorCode[ErrorCode["INTERNAL_DELETE_SESSION_ERROR"] = 15] = "INTERNAL_DELETE_SESSION_ERROR";
ErrorCode[ErrorCode["INTERNAL_DELETE_USER_ERROR"] = 16] = "INTERNAL_DELETE_USER_ERROR";
ErrorCode[ErrorCode["INTERNAL_FIND_USER_ERROR"] = 17] = "INTERNAL_FIND_USER_ERROR";
ErrorCode[ErrorCode["INTERNAL_FIND_SESSION_ERROR"] = 18] = "INTERNAL_FIND_SESSION_ERROR";
ErrorCode[ErrorCode["MAIL_NOT_SENT"] = 19] = "MAIL_NOT_SENT";
})(ErrorCode || (ErrorCode = {}));
{
"name": "@genezio/auth",
"version": "1.0.2",
"version": "2.0.0",
"description": "SDK for accessing genezio authentication system.",

@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc