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

use-jwt-manager

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-jwt-manager - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

useJwt.test.ts

7

package.json
{
"name": "use-jwt-manager",
"author": "claudio biselli",
"version": "0.1.2",
"author": {
"name": "claudio biselli",
"email": "cbiselli89@gmail.com"
},
"version": "0.1.3",
"description": "hook for jwt auth",

@@ -6,0 +9,0 @@ "repository": {

@@ -1,2 +0,2 @@

interface IUser {
interface UserDetails {
id?: number;

@@ -8,4 +8,4 @@ username?: string;

interface IUserContextReducerParams {
user?: IUser;
interface UserContextReducerParams {
user?: UserDetails;
access_token?: string;

@@ -18,26 +18,29 @@ refresh_token?: string;

interface IUserContext extends IUserContextReducerParams {
login: (user: IUser) => void;
logout: () => void;
refrshToken: () => void;
}
interface ITokenParam {
interface TokenParams {
access_token: string;
refresh_token?: string;
[x: string]: any;
}
interface useJwtManagerProps {
refresh: () => Promise<ITokenParam>;
me: { (): Promise<any>; (): Promise<IUser> };
login: { (user: any): Promise<any>; (arg0: IUser): Promise<ITokenParam> };
interface jwtManagerProps {
refresh: () => Promise<TokenParams>;
me: () => Promise<UserDetails>;
login: (user: UserDetails) => Promise<TokenParams>;
config: { TOKEN_KEY: string; REFRESH_TOKEN_KEY: string };
}
interface jwtManagerContext extends IUserContextReducerParams {
login: (user: IUser) => void;
logout: () => void;
refrshToken: () => void;
interface jwtManagerContext extends UserContextReducerParams {
login: (user: UserDetails) => Promise<UserDetails>;
logout: () => Promise<boolean>;
}
export { ITokenParam, IUser, IUserContext, IUserContextReducerParams, useJwtManagerProps, jwtManagerContext };
class JwtError extends Error {
cause: any;
constructor(message: string, cause: any) {
super(message);
this.cause = cause;
this.name = 'JwtError';
}
}
export { TokenParams, UserDetails, UserContextReducerParams, jwtManagerProps, jwtManagerContext, JwtError };

@@ -1,9 +0,8 @@

import { IUser, IUserContextReducerParams } from './constants/types';
import { UserDetails, UserContextReducerParams } from './constants/types';
type Actions =
| { type: 'LOGIN'; payload: { user: IUser; access_token: string; refresh_token: string } | {} }
| { type: 'ERROR'; payload: { error: string } }
| { type: 'LOGIN'; payload: { user: UserDetails; access_token: string; refresh_token: string } | {} }
| { type: 'LOGOUT' };
const userContextReducer = (state: IUserContextReducerParams, action: Actions): IUserContextReducerParams => {
const userContextReducer = (state: UserContextReducerParams, action: Actions): UserContextReducerParams => {
switch (action.type) {

@@ -17,4 +16,2 @@ case 'LOGIN':

};
case 'ERROR':
return { ...state, ...action.payload };
case 'LOGOUT':

@@ -21,0 +18,0 @@ return { authenticated: false, initialized: true };

Sorry, the diff of this file is not supported yet

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