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 2.0.4 to 2.0.5

README.md

23

dist/cjs/authService.sdk.d.ts

@@ -19,7 +19,2 @@ /**

}
export declare class StorageManager {
private static storage;
static getStorage(): Storage;
static setStorage(storage: Storage): void;
}
export declare class AuthService {

@@ -29,2 +24,3 @@ private static notInitializedErrorMessage;

private remote;
private storage;
/**

@@ -37,2 +33,9 @@ * @method getInstance

/**
* @method setStorage
* @description Method that sets the storage that will be used to store the token.
* @param {Storage} storage - The storage that will be used to store the token.
* @returns {void}
*/
setStorage(storage: Storage): void;
/**
* @method setTokenAndRegion

@@ -110,9 +113,15 @@ * @description Method that should be called before any other method. This method sets the token and region

* @method userInfo
* @description Method that can be used to obtain information about the user. It uses the token retrieved from storage.
* @returns {Promise<User>} An object containing the user's information.
*/
userInfo(): Promise<User>;
/**
* @method userInfoForToken
* @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.
* @param {string} token The user's token.
* @returns {Promise<User>} An object containing the user's information.
*/
userInfo(token?: string | undefined): Promise<User>;
userInfoForToken(token: string): Promise<User>;
logout(): Promise<void>;
}
export { Remote };

@@ -7,3 +7,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Remote = exports.AuthService = exports.StorageManager = exports.LocalStorageWrapper = void 0;
exports.Remote = exports.AuthService = exports.LocalStorageWrapper = void 0;
const remote_1 = require("./remote");

@@ -26,18 +26,6 @@ Object.defineProperty(exports, "Remote", { enumerable: true, get: function () { return remote_1.Remote; } });

exports.LocalStorageWrapper = LocalStorageWrapper;
class StorageManager {
static getStorage() {
if (!this.storage) {
this.storage = new LocalStorageWrapper();
}
return this.storage;
}
static setStorage(storage) {
this.storage = storage;
}
}
exports.StorageManager = StorageManager;
StorageManager.storage = null;
class AuthService {
constructor() {
this.remote = null;
this.storage = null;
}

@@ -55,2 +43,3 @@ /**

this.instance.remote = new remote_1.Remote(url);
this.instance.storage = new LocalStorageWrapper();
}

@@ -61,2 +50,11 @@ }

/**
* @method setStorage
* @description Method that sets the storage that will be used to store the token.
* @param {Storage} storage - The storage that will be used to store the token.
* @returns {void}
*/
setStorage(storage) {
this.storage = storage;
}
/**
* @method setTokenAndRegion

@@ -107,7 +105,7 @@ * @description Method that should be called before any other method. This method sets the token and region

async login(email, password) {
if (!this.remote) {
if (!this.remote || !this.storage) {
throw new Error(AuthService.notInitializedErrorMessage);
}
const response = await this.remote.call("AuthService.login", email, password);
StorageManager.getStorage().setItem("token", response.token);
this.storage.setItem("token", response.token);
return response;

@@ -175,7 +173,7 @@ }

async googleRegistration(googleToken) {
if (!this.remote) {
if (!this.remote || !this.storage) {
throw new Error(AuthService.notInitializedErrorMessage);
}
const response = await this.remote.call("AuthService.googleRegistration", googleToken);
StorageManager.getStorage().setItem("token", response.token);
this.storage.setItem("token", response.token);
return response;

@@ -185,19 +183,28 @@ }

* @method userInfo
* @description Method that can be used to obtain information about the user. It uses the token retrieved from storage.
* @returns {Promise<User>} An object containing the user's information.
*/
async userInfo() {
if (!this.remote || !this.storage) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.userInfo", this.storage.getItem("token"));
}
/**
* @method userInfoForToken
* @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.
* @param {string} token The user's token.
* @returns {Promise<User>} An object containing the user's information.
*/
async userInfo(token = undefined) {
async userInfoForToken(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);
}
return await this.remote.call("AuthService.userInfo", token);
}
async logout() {
StorageManager.getStorage().removeItem("token");
if (!this.storage) {
throw new Error(AuthService.notInitializedErrorMessage);
}
this.storage.removeItem("token");
}

@@ -204,0 +211,0 @@ }

@@ -5,4 +5,4 @@ /**

*/
import { AuthService } from "./authService.sdk";
import { AuthService, LocalStorageWrapper, Storage } from "./authService.sdk";
import { User, ErrorCode, UserLoginResponse } from "./models/UserTypes";
export { AuthService, User, ErrorCode, UserLoginResponse };
export { AuthService, User, ErrorCode, UserLoginResponse, LocalStorageWrapper, Storage };

@@ -7,6 +7,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorCode = exports.AuthService = void 0;
exports.LocalStorageWrapper = 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; } });
Object.defineProperty(exports, "LocalStorageWrapper", { enumerable: true, get: function () { return authService_sdk_1.LocalStorageWrapper; } });
const UserTypes_1 = require("./models/UserTypes");
Object.defineProperty(exports, "ErrorCode", { enumerable: true, get: function () { return UserTypes_1.ErrorCode; } });

@@ -19,7 +19,2 @@ /**

}
export declare class StorageManager {
private static storage;
static getStorage(): Storage;
static setStorage(storage: Storage): void;
}
export declare class AuthService {

@@ -29,2 +24,3 @@ private static notInitializedErrorMessage;

private remote;
private storage;
/**

@@ -37,2 +33,9 @@ * @method getInstance

/**
* @method setStorage
* @description Method that sets the storage that will be used to store the token.
* @param {Storage} storage - The storage that will be used to store the token.
* @returns {void}
*/
setStorage(storage: Storage): void;
/**
* @method setTokenAndRegion

@@ -110,9 +113,15 @@ * @description Method that should be called before any other method. This method sets the token and region

* @method userInfo
* @description Method that can be used to obtain information about the user. It uses the token retrieved from storage.
* @returns {Promise<User>} An object containing the user's information.
*/
userInfo(): Promise<User>;
/**
* @method userInfoForToken
* @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.
* @param {string} token The user's token.
* @returns {Promise<User>} An object containing the user's information.
*/
userInfo(token?: string | undefined): Promise<User>;
userInfoForToken(token: string): Promise<User>;
logout(): Promise<void>;
}
export { Remote };

@@ -20,17 +20,6 @@ /**

}
export class StorageManager {
static getStorage() {
if (!this.storage) {
this.storage = new LocalStorageWrapper();
}
return this.storage;
}
static setStorage(storage) {
this.storage = storage;
}
}
StorageManager.storage = null;
export class AuthService {
constructor() {
this.remote = null;
this.storage = null;
}

@@ -48,2 +37,3 @@ /**

this.instance.remote = new Remote(url);
this.instance.storage = new LocalStorageWrapper();
}

@@ -54,2 +44,11 @@ }

/**
* @method setStorage
* @description Method that sets the storage that will be used to store the token.
* @param {Storage} storage - The storage that will be used to store the token.
* @returns {void}
*/
setStorage(storage) {
this.storage = storage;
}
/**
* @method setTokenAndRegion

@@ -100,7 +99,7 @@ * @description Method that should be called before any other method. This method sets the token and region

async login(email, password) {
if (!this.remote) {
if (!this.remote || !this.storage) {
throw new Error(AuthService.notInitializedErrorMessage);
}
const response = await this.remote.call("AuthService.login", email, password);
StorageManager.getStorage().setItem("token", response.token);
this.storage.setItem("token", response.token);
return response;

@@ -168,7 +167,7 @@ }

async googleRegistration(googleToken) {
if (!this.remote) {
if (!this.remote || !this.storage) {
throw new Error(AuthService.notInitializedErrorMessage);
}
const response = await this.remote.call("AuthService.googleRegistration", googleToken);
StorageManager.getStorage().setItem("token", response.token);
this.storage.setItem("token", response.token);
return response;

@@ -178,19 +177,28 @@ }

* @method userInfo
* @description Method that can be used to obtain information about the user. It uses the token retrieved from storage.
* @returns {Promise<User>} An object containing the user's information.
*/
async userInfo() {
if (!this.remote || !this.storage) {
throw new Error(AuthService.notInitializedErrorMessage);
}
return await this.remote.call("AuthService.userInfo", this.storage.getItem("token"));
}
/**
* @method userInfoForToken
* @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.
* @param {string} token The user's token.
* @returns {Promise<User>} An object containing the user's information.
*/
async userInfo(token = undefined) {
async userInfoForToken(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);
}
return await this.remote.call("AuthService.userInfo", token);
}
async logout() {
StorageManager.getStorage().removeItem("token");
if (!this.storage) {
throw new Error(AuthService.notInitializedErrorMessage);
}
this.storage.removeItem("token");
}

@@ -197,0 +205,0 @@ }

@@ -5,4 +5,4 @@ /**

*/
import { AuthService } from "./authService.sdk";
import { AuthService, LocalStorageWrapper, Storage } from "./authService.sdk";
import { User, ErrorCode, UserLoginResponse } from "./models/UserTypes";
export { AuthService, User, ErrorCode, UserLoginResponse };
export { AuthService, User, ErrorCode, UserLoginResponse, LocalStorageWrapper, Storage };

@@ -5,4 +5,4 @@ /**

*/
import { AuthService } from "./authService.sdk";
import { AuthService, LocalStorageWrapper } from "./authService.sdk";
import { ErrorCode } from "./models/UserTypes";
export { AuthService, ErrorCode };
export { AuthService, ErrorCode, LocalStorageWrapper };
{
"name": "@genezio/auth",
"version": "2.0.4",
"version": "2.0.5",
"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