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

react-auth-kit

Package Overview
Dependencies
Maintainers
1
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-auth-kit - npm Package Compare versions

Comparing version 1.4.1-0 to 1.4.2-0

174

dist/index.js

@@ -53,2 +53,3 @@ 'use strict';

this.cookieSecure = cookieSecure;
this.isUsingRefreshToken = !!this.authStorageName;
this.authStorageTypeName = this.authStorageName + "_type";

@@ -94,8 +95,7 @@ this.refreshTokenTimeName = this.refreshTokenName ?

var stateCookie = Cookies__default['default'].get(this.stateStorageName);
var refreshToken = this.refreshTokenName != null ?
Cookies__default['default'].get(this.refreshTokenName) :
null;
var refreshTokenTime = this.refreshTokenTimeName != null ?
Cookies__default['default'].get(this.refreshTokenTimeName) :
null;
var refreshToken = this.isUsingRefreshToken &&
this.refreshTokenName != null ? Cookies__default['default'].get(this.refreshTokenName) : null;
var refreshTokenTime = this.isUsingRefreshToken &&
this.refreshTokenTimeName != null ?
Cookies__default['default'].get(this.refreshTokenTimeName) : null;
return this.checkTokenExist(authToken, authTokenType, authTokenTime, stateCookie, refreshToken, refreshTokenTime);

@@ -118,8 +118,8 @@ };

var stateCookie = localStorage.getItem(this.stateStorageName);
var refreshToken = this.refreshTokenName != null ?
localStorage.getItem(this.refreshTokenName) :
null;
var refreshTokenTime = this.refreshTokenTimeName != null ?
localStorage.getItem(this.refreshTokenTimeName) :
null;
var refreshToken = this.isUsingRefreshToken &&
this.refreshTokenName != null ?
localStorage.getItem(this.refreshTokenName) : null;
var refreshTokenTime = this.isUsingRefreshToken &&
this.refreshTokenTimeName != null ?
localStorage.getItem(this.refreshTokenTimeName) : null;
return this.checkTokenExist(authToken, authTokenType, authTokenTime, stateCookie, refreshToken, refreshTokenTime);

@@ -153,5 +153,6 @@ };

authTokenType: authTokenType,
refreshToken: !!this.refreshTokenName && !!refreshToken ?
isUsingRefreshToken: this.isUsingRefreshToken,
refreshToken: this.isUsingRefreshToken && !!refreshToken ?
refreshToken : null,
refreshTokenExpireAt: !!this.refreshTokenTimeName &&
refreshTokenExpireAt: this.isUsingRefreshToken &&
!!refreshTokenTime ? new Date(refreshTokenTime) : null,

@@ -166,2 +167,3 @@ expireAt: expiresAt,

authTokenType: null,
isUsingRefreshToken: this.isUsingRefreshToken,
refreshToken: null,

@@ -178,2 +180,3 @@ expireAt: null,

authTokenType: null,
isUsingRefreshToken: this.isUsingRefreshToken,
refreshToken: null,

@@ -246,3 +249,3 @@ expireAt: null,

});
Cookies__default['default'].set(this.authTimeStorageName, expiresAt, {
Cookies__default['default'].set(this.authTimeStorageName, expiresAt.toISOString(), {
expires: expiresAt,

@@ -257,3 +260,4 @@ domain: this.cookieDomain,

});
if (!!this.refreshTokenName && !!refreshToken) {
if (this.isUsingRefreshToken && !!this.refreshTokenName &&
!!refreshToken) {
Cookies__default['default'].set(this.refreshTokenName, refreshToken, {

@@ -265,3 +269,4 @@ expires: expiresAt,

}
if (!!this.refreshTokenTimeName && !!refreshTokenExpiresAt) {
if (this.isUsingRefreshToken && !!this.refreshTokenTimeName &&
!!refreshTokenExpiresAt) {
Cookies__default['default'].set(this.refreshTokenTimeName, refreshTokenExpiresAt.toISOString(), {

@@ -289,6 +294,8 @@ expires: expiresAt,

localStorage.setItem(this.stateStorageName, JSON.stringify(authState));
if (!!this.refreshTokenName && !!refreshToken) {
if (this.isUsingRefreshToken && !!this.refreshTokenName &&
!!refreshToken) {
localStorage.setItem(this.refreshTokenName, refreshToken);
}
if (!!this.refreshTokenTimeName && !!refreshTokenExpiresAt) {
if (this.isUsingRefreshToken && !!this.refreshTokenTimeName &&
!!refreshTokenExpiresAt) {
localStorage.setItem(this.refreshTokenTimeName, refreshTokenExpiresAt.toISOString());

@@ -315,6 +322,6 @@ }

Cookies__default['default'].remove(this.stateStorageName);
if (!!this.refreshTokenName) {
if (this.isUsingRefreshToken && !!this.refreshTokenName) {
Cookies__default['default'].remove(this.refreshTokenName);
}
if (!!this.refreshTokenTimeName) {
if (this.isUsingRefreshToken && !!this.refreshTokenTimeName) {
Cookies__default['default'].remove(this.refreshTokenTimeName);

@@ -330,6 +337,6 @@ }

localStorage.removeItem(this.stateStorageName);
if (!!this.refreshTokenName) {
if (this.isUsingRefreshToken && !!this.refreshTokenName) {
localStorage.removeItem(this.refreshTokenName);
}
if (!!this.refreshTokenTimeName) {
if (this.isUsingRefreshToken && !!this.refreshTokenTimeName) {
localStorage.removeItem(this.refreshTokenTimeName);

@@ -346,2 +353,3 @@ }

authToken: null,
isUsingRefreshToken: false,
refreshToken: null,

@@ -399,2 +407,28 @@ refreshTokenExpireAt: null,

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/**

@@ -417,10 +451,3 @@ * Private Route for Components

else {
context.setAuthState({
authToken: null,
authTokenType: null,
expireAt: null,
authState: null,
refreshToken: null,
refreshTokenExpireAt: null,
});
context.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null, refreshToken: null, refreshTokenExpireAt: null })); });
return false;

@@ -445,28 +472,2 @@ }

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/**

@@ -522,10 +523,3 @@ *@author Arkadip Bhattacharya <in2arkadipb13@gmail.com>

else {
c.setAuthState({
authToken: null,
authTokenType: null,
expireAt: null,
authState: null,
refreshToken: null,
refreshTokenExpireAt: null,
});
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null, refreshToken: null, refreshTokenExpireAt: null })); });
return false;

@@ -545,7 +539,15 @@ }

var signIn = function (signInConfig) {
var token = signInConfig.token, tokenType = signInConfig.tokenType, authState = signInConfig.authState, expiresIn = signInConfig.expiresIn;
var token = signInConfig.token, tokenType = signInConfig.tokenType, authState = signInConfig.authState, expiresIn = signInConfig.expiresIn, refreshToken = signInConfig.refreshToken, refreshTokenExpireIn = signInConfig.refreshTokenExpireIn;
if ((refreshToken || refreshTokenExpireIn) &&
!c.authState.isUsingRefreshToken) {
throw new Error('The app doesn\'t implement \'refreshToken\' feature.\n' +
'So you have to implement refresh token feature from ' +
'\'AuthProvider\' before using it.');
}
var expTime = new Date(new Date().getTime() + expiresIn * 60 * 1000);
var refreshTokenExpireAt = !!refreshTokenExpireIn ?
new Date(new Date().getTime() + refreshTokenExpireIn * 60 * 1000) : null;
try {
if (c) {
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: token, authTokenType: tokenType, expireAt: expTime, authState: authState })); });
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: token, authTokenType: tokenType, expireAt: expTime, authState: authState, refreshToken: !!refreshToken ? refreshToken : null, refreshTokenExpireAt: refreshTokenExpireAt })); });
return true;

@@ -570,3 +572,3 @@ }

if (c === null || c === void 0 ? void 0 : c.authState.authToken) {
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null })); });
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, refreshToken: null, refreshTokenExpireAt: null, expireAt: null, authState: null })); });
console.log('RAJ :: Signing Out');

@@ -602,2 +604,8 @@ return true;

var token = signInConfig.token, tokenType = signInConfig.tokenType, authState = signInConfig.authState, expiresIn = signInConfig.expiresIn, refreshToken = signInConfig.refreshToken, refreshTokenExpireIn = signInConfig.refreshTokenExpireIn;
if ((refreshToken || refreshTokenExpireIn) &&
!context.authState.isUsingRefreshToken) {
throw new Error('The app doesn\'t implement \'refreshToken\' feature.\n' +
'So you have to implement refresh token feature from ' +
'\'AuthProvider\' before using it.');
}
var expTime = new Date(new Date().getTime() + expiresIn * 60 * 1000);

@@ -711,2 +719,7 @@ var refreshTokenExpireAt = !!refreshTokenExpireIn ?

this.context = context;
if (!this.context.authState.isUsingRefreshToken) {
throw new Error('The app doesn\'t implement \'refreshToken\' feature.\n' +
'So you have to implement refresh token feature from ' +
'\'AuthProvider\' before using it.');
}
}

@@ -833,10 +846,3 @@ /**

else {
context.setAuthState({
authToken: null,
authTokenType: null,
expireAt: null,
authState: null,
refreshToken: null,
refreshTokenExpireAt: null,
});
context.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null, refreshToken: null, refreshTokenExpireAt: null })); });
return false;

@@ -863,2 +869,9 @@ }

var token = signInConfig.token, tokenType = signInConfig.tokenType, authState = signInConfig.authState, expiresIn = signInConfig.expiresIn, refreshToken = signInConfig.refreshToken, refreshTokenExpireIn = signInConfig.refreshTokenExpireIn;
if ((refreshToken || refreshTokenExpireIn) &&
!c.authState.isUsingRefreshToken) {
throw new Error('The app doesn\'t implement ' +
'\'refreshToken\' feature.\n' +
'So you have to implement refresh token feature from ' +
'\'AuthProvider\' before using it.');
}
var expTime = new Date(new Date().getTime() + expiresIn * 60 * 1000);

@@ -996,10 +1009,3 @@ var refreshTokenExpireAt = !!refreshTokenExpireIn ?

else {
c.setAuthState({
authToken: null,
authTokenType: null,
expireAt: null,
authState: null,
refreshToken: null,
refreshTokenExpireAt: null,
});
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null, refreshToken: null, refreshTokenExpireAt: null })); });
return React.createElement(Component, __assign({}, props, { isAuth: false }));

@@ -1006,0 +1012,0 @@ }

@@ -45,2 +45,3 @@ import { createContext, useState, useEffect, createElement, useContext } from 'react';

this.cookieSecure = cookieSecure;
this.isUsingRefreshToken = !!this.authStorageName;
this.authStorageTypeName = this.authStorageName + "_type";

@@ -86,8 +87,7 @@ this.refreshTokenTimeName = this.refreshTokenName ?

var stateCookie = Cookies.get(this.stateStorageName);
var refreshToken = this.refreshTokenName != null ?
Cookies.get(this.refreshTokenName) :
null;
var refreshTokenTime = this.refreshTokenTimeName != null ?
Cookies.get(this.refreshTokenTimeName) :
null;
var refreshToken = this.isUsingRefreshToken &&
this.refreshTokenName != null ? Cookies.get(this.refreshTokenName) : null;
var refreshTokenTime = this.isUsingRefreshToken &&
this.refreshTokenTimeName != null ?
Cookies.get(this.refreshTokenTimeName) : null;
return this.checkTokenExist(authToken, authTokenType, authTokenTime, stateCookie, refreshToken, refreshTokenTime);

@@ -110,8 +110,8 @@ };

var stateCookie = localStorage.getItem(this.stateStorageName);
var refreshToken = this.refreshTokenName != null ?
localStorage.getItem(this.refreshTokenName) :
null;
var refreshTokenTime = this.refreshTokenTimeName != null ?
localStorage.getItem(this.refreshTokenTimeName) :
null;
var refreshToken = this.isUsingRefreshToken &&
this.refreshTokenName != null ?
localStorage.getItem(this.refreshTokenName) : null;
var refreshTokenTime = this.isUsingRefreshToken &&
this.refreshTokenTimeName != null ?
localStorage.getItem(this.refreshTokenTimeName) : null;
return this.checkTokenExist(authToken, authTokenType, authTokenTime, stateCookie, refreshToken, refreshTokenTime);

@@ -145,5 +145,6 @@ };

authTokenType: authTokenType,
refreshToken: !!this.refreshTokenName && !!refreshToken ?
isUsingRefreshToken: this.isUsingRefreshToken,
refreshToken: this.isUsingRefreshToken && !!refreshToken ?
refreshToken : null,
refreshTokenExpireAt: !!this.refreshTokenTimeName &&
refreshTokenExpireAt: this.isUsingRefreshToken &&
!!refreshTokenTime ? new Date(refreshTokenTime) : null,

@@ -158,2 +159,3 @@ expireAt: expiresAt,

authTokenType: null,
isUsingRefreshToken: this.isUsingRefreshToken,
refreshToken: null,

@@ -170,2 +172,3 @@ expireAt: null,

authTokenType: null,
isUsingRefreshToken: this.isUsingRefreshToken,
refreshToken: null,

@@ -238,3 +241,3 @@ expireAt: null,

});
Cookies.set(this.authTimeStorageName, expiresAt, {
Cookies.set(this.authTimeStorageName, expiresAt.toISOString(), {
expires: expiresAt,

@@ -249,3 +252,4 @@ domain: this.cookieDomain,

});
if (!!this.refreshTokenName && !!refreshToken) {
if (this.isUsingRefreshToken && !!this.refreshTokenName &&
!!refreshToken) {
Cookies.set(this.refreshTokenName, refreshToken, {

@@ -257,3 +261,4 @@ expires: expiresAt,

}
if (!!this.refreshTokenTimeName && !!refreshTokenExpiresAt) {
if (this.isUsingRefreshToken && !!this.refreshTokenTimeName &&
!!refreshTokenExpiresAt) {
Cookies.set(this.refreshTokenTimeName, refreshTokenExpiresAt.toISOString(), {

@@ -281,6 +286,8 @@ expires: expiresAt,

localStorage.setItem(this.stateStorageName, JSON.stringify(authState));
if (!!this.refreshTokenName && !!refreshToken) {
if (this.isUsingRefreshToken && !!this.refreshTokenName &&
!!refreshToken) {
localStorage.setItem(this.refreshTokenName, refreshToken);
}
if (!!this.refreshTokenTimeName && !!refreshTokenExpiresAt) {
if (this.isUsingRefreshToken && !!this.refreshTokenTimeName &&
!!refreshTokenExpiresAt) {
localStorage.setItem(this.refreshTokenTimeName, refreshTokenExpiresAt.toISOString());

@@ -307,6 +314,6 @@ }

Cookies.remove(this.stateStorageName);
if (!!this.refreshTokenName) {
if (this.isUsingRefreshToken && !!this.refreshTokenName) {
Cookies.remove(this.refreshTokenName);
}
if (!!this.refreshTokenTimeName) {
if (this.isUsingRefreshToken && !!this.refreshTokenTimeName) {
Cookies.remove(this.refreshTokenTimeName);

@@ -322,6 +329,6 @@ }

localStorage.removeItem(this.stateStorageName);
if (!!this.refreshTokenName) {
if (this.isUsingRefreshToken && !!this.refreshTokenName) {
localStorage.removeItem(this.refreshTokenName);
}
if (!!this.refreshTokenTimeName) {
if (this.isUsingRefreshToken && !!this.refreshTokenTimeName) {
localStorage.removeItem(this.refreshTokenTimeName);

@@ -338,2 +345,3 @@ }

authToken: null,
isUsingRefreshToken: false,
refreshToken: null,

@@ -391,2 +399,28 @@ refreshTokenExpireAt: null,

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/**

@@ -409,10 +443,3 @@ * Private Route for Components

else {
context.setAuthState({
authToken: null,
authTokenType: null,
expireAt: null,
authState: null,
refreshToken: null,
refreshTokenExpireAt: null,
});
context.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null, refreshToken: null, refreshTokenExpireAt: null })); });
return false;

@@ -437,28 +464,2 @@ }

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
/**

@@ -514,10 +515,3 @@ *@author Arkadip Bhattacharya <in2arkadipb13@gmail.com>

else {
c.setAuthState({
authToken: null,
authTokenType: null,
expireAt: null,
authState: null,
refreshToken: null,
refreshTokenExpireAt: null,
});
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null, refreshToken: null, refreshTokenExpireAt: null })); });
return false;

@@ -537,7 +531,15 @@ }

var signIn = function (signInConfig) {
var token = signInConfig.token, tokenType = signInConfig.tokenType, authState = signInConfig.authState, expiresIn = signInConfig.expiresIn;
var token = signInConfig.token, tokenType = signInConfig.tokenType, authState = signInConfig.authState, expiresIn = signInConfig.expiresIn, refreshToken = signInConfig.refreshToken, refreshTokenExpireIn = signInConfig.refreshTokenExpireIn;
if ((refreshToken || refreshTokenExpireIn) &&
!c.authState.isUsingRefreshToken) {
throw new Error('The app doesn\'t implement \'refreshToken\' feature.\n' +
'So you have to implement refresh token feature from ' +
'\'AuthProvider\' before using it.');
}
var expTime = new Date(new Date().getTime() + expiresIn * 60 * 1000);
var refreshTokenExpireAt = !!refreshTokenExpireIn ?
new Date(new Date().getTime() + refreshTokenExpireIn * 60 * 1000) : null;
try {
if (c) {
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: token, authTokenType: tokenType, expireAt: expTime, authState: authState })); });
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: token, authTokenType: tokenType, expireAt: expTime, authState: authState, refreshToken: !!refreshToken ? refreshToken : null, refreshTokenExpireAt: refreshTokenExpireAt })); });
return true;

@@ -562,3 +564,3 @@ }

if (c === null || c === void 0 ? void 0 : c.authState.authToken) {
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null })); });
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, refreshToken: null, refreshTokenExpireAt: null, expireAt: null, authState: null })); });
console.log('RAJ :: Signing Out');

@@ -594,2 +596,8 @@ return true;

var token = signInConfig.token, tokenType = signInConfig.tokenType, authState = signInConfig.authState, expiresIn = signInConfig.expiresIn, refreshToken = signInConfig.refreshToken, refreshTokenExpireIn = signInConfig.refreshTokenExpireIn;
if ((refreshToken || refreshTokenExpireIn) &&
!context.authState.isUsingRefreshToken) {
throw new Error('The app doesn\'t implement \'refreshToken\' feature.\n' +
'So you have to implement refresh token feature from ' +
'\'AuthProvider\' before using it.');
}
var expTime = new Date(new Date().getTime() + expiresIn * 60 * 1000);

@@ -703,2 +711,7 @@ var refreshTokenExpireAt = !!refreshTokenExpireIn ?

this.context = context;
if (!this.context.authState.isUsingRefreshToken) {
throw new Error('The app doesn\'t implement \'refreshToken\' feature.\n' +
'So you have to implement refresh token feature from ' +
'\'AuthProvider\' before using it.');
}
}

@@ -825,10 +838,3 @@ /**

else {
context.setAuthState({
authToken: null,
authTokenType: null,
expireAt: null,
authState: null,
refreshToken: null,
refreshTokenExpireAt: null,
});
context.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null, refreshToken: null, refreshTokenExpireAt: null })); });
return false;

@@ -855,2 +861,9 @@ }

var token = signInConfig.token, tokenType = signInConfig.tokenType, authState = signInConfig.authState, expiresIn = signInConfig.expiresIn, refreshToken = signInConfig.refreshToken, refreshTokenExpireIn = signInConfig.refreshTokenExpireIn;
if ((refreshToken || refreshTokenExpireIn) &&
!c.authState.isUsingRefreshToken) {
throw new Error('The app doesn\'t implement ' +
'\'refreshToken\' feature.\n' +
'So you have to implement refresh token feature from ' +
'\'AuthProvider\' before using it.');
}
var expTime = new Date(new Date().getTime() + expiresIn * 60 * 1000);

@@ -988,10 +1001,3 @@ var refreshTokenExpireAt = !!refreshTokenExpireIn ?

else {
c.setAuthState({
authToken: null,
authTokenType: null,
expireAt: null,
authState: null,
refreshToken: null,
refreshTokenExpireAt: null,
});
c.setAuthState(function (prevState) { return (__assign(__assign({}, prevState), { authToken: null, authTokenType: null, expireAt: null, authState: null, refreshToken: null, refreshTokenExpireAt: null })); });
return createElement(Component, __assign({}, props, { isAuth: false }));

@@ -998,0 +1004,0 @@ }

@@ -1,3 +0,17 @@

/*! react-auth-kit v1.4.1-0 | Apache-2.0 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("js-cookie"),require("react-router-dom")):"function"==typeof define&&define.amd?define(["exports","react","js-cookie","react-router-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactAuthKit={},e.React,e.Cookies,e.reactRouterDom)}(this,(function(e,t,n,r){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(n),u=function(){function e(e){var t=e.authStorageName,n=e.authStorageType,r=e.authTimeStorageName,a=e.stateStorageName,o=e.refreshTokenName,u=e.cookieDomain,i=e.cookieSecure;this.authStorageType=n,this.authStorageName=t,this.authTimeStorageName=r,this.stateStorageName=a,this.refreshTokenName=o,this.cookieDomain=u,this.cookieSecure=i,this.authStorageTypeName=this.authStorageName+"_type",this.refreshTokenTimeName=this.refreshTokenName?this.refreshTokenName+"_time":null}return e.prototype.initialToken=function(){return"cookie"===this.authStorageType?this.initialCookieToken_():this.initialLSToken_()},e.prototype.initialCookieToken_=function(){var e=o.default.get(this.authStorageName),t=o.default.get(this.authStorageTypeName),n=o.default.get(this.authTimeStorageName),r=o.default.get(this.stateStorageName),a=null!=this.refreshTokenName?o.default.get(this.refreshTokenName):null,u=null!=this.refreshTokenTimeName?o.default.get(this.refreshTokenTimeName):null;return this.checkTokenExist(e,t,n,r,a,u)},e.prototype.initialLSToken_=function(){var e=localStorage.getItem(this.authStorageName),t=localStorage.getItem(this.authStorageTypeName),n=localStorage.getItem(this.authTimeStorageName),r=localStorage.getItem(this.stateStorageName),a=null!=this.refreshTokenName?localStorage.getItem(this.refreshTokenName):null,o=null!=this.refreshTokenTimeName?localStorage.getItem(this.refreshTokenTimeName):null;return this.checkTokenExist(e,t,n,r,a,o)},e.prototype.checkTokenExist=function(e,t,n,r,a,o){if(!(e&&t&&n&&r))return{authToken:null,authTokenType:null,refreshToken:null,expireAt:null,authState:null,refreshTokenExpireAt:null};var u=new Date(n);try{var i=JSON.parse(r);return{authToken:e,authTokenType:t,refreshToken:this.refreshTokenName&&a?a:null,refreshTokenExpireAt:this.refreshTokenTimeName&&o?new Date(o):null,expireAt:u,authState:i}}catch(e){return{authToken:null,authTokenType:null,refreshToken:null,expireAt:null,authState:null,refreshTokenExpireAt:null}}},e.prototype.syncTokens=function(e){void 0===e.authToken||null===e.authTokenType||null===e.authToken||null===e.expireAt||null===e.authState?this.removeToken():this.setToken(e.authToken,e.authTokenType,e.refreshToken,e.refreshTokenExpireAt,e.expireAt,e.authState)},e.prototype.setToken=function(e,t,n,r,a,o){"cookie"===this.authStorageType?this.setCookieToken_(e,t,n,a,r,o):this.setLSToken_(e,t,n,a,r,o)},e.prototype.setCookieToken_=function(e,t,n,r,a,u){o.default.set(this.authStorageName,e,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),o.default.set(this.authStorageTypeName,t,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),o.default.set(this.authTimeStorageName,r,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),o.default.set(this.stateStorageName,u,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),this.refreshTokenName&&n&&o.default.set(this.refreshTokenName,n,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),this.refreshTokenTimeName&&a&&o.default.set(this.refreshTokenTimeName,a.toISOString(),{expires:r,domain:this.cookieDomain,secure:this.cookieSecure})},e.prototype.setLSToken_=function(e,t,n,r,a,o){localStorage.setItem(this.authStorageName,e),localStorage.setItem(this.authStorageTypeName,t),localStorage.setItem(this.authTimeStorageName,r.toISOString()),localStorage.setItem(this.stateStorageName,JSON.stringify(o)),this.refreshTokenName&&n&&localStorage.setItem(this.refreshTokenName,n),this.refreshTokenTimeName&&a&&localStorage.setItem(this.refreshTokenTimeName,a.toISOString())},e.prototype.removeToken=function(){"cookie"===this.authStorageType?this.removeCookieToken_():this.removeLSToken_()},e.prototype.removeCookieToken_=function(){o.default.remove(this.authStorageName),o.default.remove(this.authTimeStorageName),o.default.remove(this.stateStorageName),this.refreshTokenName&&o.default.remove(this.refreshTokenName),this.refreshTokenTimeName&&o.default.remove(this.refreshTokenTimeName)},e.prototype.removeLSToken_=function(){localStorage.removeItem(this.authStorageName),localStorage.removeItem(this.authTimeStorageName),localStorage.removeItem(this.stateStorageName),this.refreshTokenName&&localStorage.removeItem(this.refreshTokenName),this.refreshTokenTimeName&&localStorage.removeItem(this.refreshTokenTimeName)},e}(),i=t.createContext({authState:{authTokenType:null,authState:null,authToken:null,refreshToken:null,refreshTokenExpireAt:null,expireAt:null},setAuthState:function(){}}),h=function(e){var n=e.children,r=e.authStorageType,a=e.authStorageName,o=e.authTimeStorageName,h=e.stateStorageName,s=e.refreshTokenName,l=e.cookieDomain,c=e.cookieSecure;if("cookie"===r&&!l)throw new Error("authStorageType 'cookie' requires 'cookieDomain' and 'cookieSecure' in AuthProvider");var T=new u({authTimeStorageName:o,authStorageType:r,authStorageName:a,refreshTokenName:s,cookieDomain:l,cookieSecure:c,stateStorageName:h}),k=t.useState(T.initialToken()),f=k[0],m=k[1];return t.useEffect((function(){T.syncTokens(f)}),[f]),t.createElement(i.Provider,{value:{authState:f,setAuthState:m}},n)};h.defaultProps={authStorageType:"cookie",authStorageName:"_auth_token",authTimeStorageName:"_auth_time",stateStorageName:"_auth_state",cookieSecure:!0};var s=i.Consumer,l=function(){return(l=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};var c=function(){function e(e){this.context=e}return e.prototype.getCurrentRefreshToken=function(){return{refreshToken:this.context.authState.refreshToken,refreshTokenExpireAt:this.context.authState.refreshTokenExpireAt}},e.prototype.getCurrentAuthState=function(){return{authToken:this.context.authState.authTokenType,authTokenType:this.context.authState.authToken,expireAt:this.context.authState.expireAt}},e.prototype.getCurrentUserState=function(){return this.context.authState.authState},e.prototype.updateRefreshToken=function(e,t){var n=new Date((new Date).getTime()+60*t*1e3);this.context.setAuthState((function(t){return l(l({},t),{refreshToken:e,refreshTokenExpireAt:n})}))},e.prototype.updateAuthState=function(e,t,n){var r={authToken:e};if(void 0!==t&&Object.assign(r,{authTokenType:t}),void 0!==n){var a=new Date((new Date).getTime()+60*n*1e3);Object.assign(r,{expireAt:a})}this.context.setAuthState((function(e){return l(l({},e),r)}))},e.prototype.updateUserState=function(e){this.context.setAuthState((function(t){return l(l({},t),{authState:e})}))},e}();e.AuthProvider=h,e.PrivateRoute=function(e){var n=t.useContext(i),a=e.component,o=e.loginPath,u=e.strict,h=e.sensitive,s=e.exact,l=e.path,c=e.location,T=e.render;return t.createElement(r.Route,{location:c,path:l,exact:s,sensitive:h,strict:u,render:function(e){return(null==n?void 0:n.authState.authToken)&&(null==n?void 0:n.authState.expireAt)&&(new Date(n.authState.expireAt)>new Date||(n.setAuthState({authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null}),0))?a?t.createElement(a,e):T?T(e):null:t.createElement(r.Redirect,{to:o})}})},e.useAuth=
/*! react-auth-kit v1.4.2-0 | Apache-2.0 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("js-cookie"),require("react-router-dom")):"function"==typeof define&&define.amd?define(["exports","react","js-cookie","react-router-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactAuthKit={},e.React,e.Cookies,e.reactRouterDom)}(this,(function(e,t,n,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(n),u=function(){function e(e){var t=e.authStorageName,n=e.authStorageType,r=e.authTimeStorageName,o=e.stateStorageName,a=e.refreshTokenName,u=e.cookieDomain,i=e.cookieSecure;this.authStorageType=n,this.authStorageName=t,this.authTimeStorageName=r,this.stateStorageName=o,this.refreshTokenName=a,this.cookieDomain=u,this.cookieSecure=i,this.isUsingRefreshToken=!!this.authStorageName,this.authStorageTypeName=this.authStorageName+"_type",this.refreshTokenTimeName=this.refreshTokenName?this.refreshTokenName+"_time":null}return e.prototype.initialToken=function(){return"cookie"===this.authStorageType?this.initialCookieToken_():this.initialLSToken_()},e.prototype.initialCookieToken_=function(){var e=a.default.get(this.authStorageName),t=a.default.get(this.authStorageTypeName),n=a.default.get(this.authTimeStorageName),r=a.default.get(this.stateStorageName),o=this.isUsingRefreshToken&&null!=this.refreshTokenName?a.default.get(this.refreshTokenName):null,u=this.isUsingRefreshToken&&null!=this.refreshTokenTimeName?a.default.get(this.refreshTokenTimeName):null;return this.checkTokenExist(e,t,n,r,o,u)},e.prototype.initialLSToken_=function(){var e=localStorage.getItem(this.authStorageName),t=localStorage.getItem(this.authStorageTypeName),n=localStorage.getItem(this.authTimeStorageName),r=localStorage.getItem(this.stateStorageName),o=this.isUsingRefreshToken&&null!=this.refreshTokenName?localStorage.getItem(this.refreshTokenName):null,a=this.isUsingRefreshToken&&null!=this.refreshTokenTimeName?localStorage.getItem(this.refreshTokenTimeName):null;return this.checkTokenExist(e,t,n,r,o,a)},e.prototype.checkTokenExist=function(e,t,n,r,o,a){if(!(e&&t&&n&&r))return{authToken:null,authTokenType:null,isUsingRefreshToken:this.isUsingRefreshToken,refreshToken:null,expireAt:null,authState:null,refreshTokenExpireAt:null};var u=new Date(n);try{var i=JSON.parse(r);return{authToken:e,authTokenType:t,isUsingRefreshToken:this.isUsingRefreshToken,refreshToken:this.isUsingRefreshToken&&o?o:null,refreshTokenExpireAt:this.isUsingRefreshToken&&a?new Date(a):null,expireAt:u,authState:i}}catch(e){return{authToken:null,authTokenType:null,isUsingRefreshToken:this.isUsingRefreshToken,refreshToken:null,expireAt:null,authState:null,refreshTokenExpireAt:null}}},e.prototype.syncTokens=function(e){void 0===e.authToken||null===e.authTokenType||null===e.authToken||null===e.expireAt||null===e.authState?this.removeToken():this.setToken(e.authToken,e.authTokenType,e.refreshToken,e.refreshTokenExpireAt,e.expireAt,e.authState)},e.prototype.setToken=function(e,t,n,r,o,a){"cookie"===this.authStorageType?this.setCookieToken_(e,t,n,o,r,a):this.setLSToken_(e,t,n,o,r,a)},e.prototype.setCookieToken_=function(e,t,n,r,o,u){a.default.set(this.authStorageName,e,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),a.default.set(this.authStorageTypeName,t,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),a.default.set(this.authTimeStorageName,r.toISOString(),{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),a.default.set(this.stateStorageName,u,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),this.isUsingRefreshToken&&this.refreshTokenName&&n&&a.default.set(this.refreshTokenName,n,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),this.isUsingRefreshToken&&this.refreshTokenTimeName&&o&&a.default.set(this.refreshTokenTimeName,o.toISOString(),{expires:r,domain:this.cookieDomain,secure:this.cookieSecure})},e.prototype.setLSToken_=function(e,t,n,r,o,a){localStorage.setItem(this.authStorageName,e),localStorage.setItem(this.authStorageTypeName,t),localStorage.setItem(this.authTimeStorageName,r.toISOString()),localStorage.setItem(this.stateStorageName,JSON.stringify(a)),this.isUsingRefreshToken&&this.refreshTokenName&&n&&localStorage.setItem(this.refreshTokenName,n),this.isUsingRefreshToken&&this.refreshTokenTimeName&&o&&localStorage.setItem(this.refreshTokenTimeName,o.toISOString())},e.prototype.removeToken=function(){"cookie"===this.authStorageType?this.removeCookieToken_():this.removeLSToken_()},e.prototype.removeCookieToken_=function(){a.default.remove(this.authStorageName),a.default.remove(this.authTimeStorageName),a.default.remove(this.stateStorageName),this.isUsingRefreshToken&&this.refreshTokenName&&a.default.remove(this.refreshTokenName),this.isUsingRefreshToken&&this.refreshTokenTimeName&&a.default.remove(this.refreshTokenTimeName)},e.prototype.removeLSToken_=function(){localStorage.removeItem(this.authStorageName),localStorage.removeItem(this.authTimeStorageName),localStorage.removeItem(this.stateStorageName),this.isUsingRefreshToken&&this.refreshTokenName&&localStorage.removeItem(this.refreshTokenName),this.isUsingRefreshToken&&this.refreshTokenTimeName&&localStorage.removeItem(this.refreshTokenTimeName)},e}(),i=t.createContext({authState:{authTokenType:null,authState:null,authToken:null,isUsingRefreshToken:!1,refreshToken:null,refreshTokenExpireAt:null,expireAt:null},setAuthState:function(){}}),h=function(e){var n=e.children,r=e.authStorageType,o=e.authStorageName,a=e.authTimeStorageName,h=e.stateStorageName,s=e.refreshTokenName,l=e.cookieDomain,T=e.cookieSecure;if("cookie"===r&&!l)throw new Error("authStorageType 'cookie' requires 'cookieDomain' and 'cookieSecure' in AuthProvider");var f=new u({authTimeStorageName:a,authStorageType:r,authStorageName:o,refreshTokenName:s,cookieDomain:l,cookieSecure:T,stateStorageName:h}),c=t.useState(f.initialToken()),k=c[0],m=c[1];return t.useEffect((function(){f.syncTokens(k)}),[k]),t.createElement(i.Provider,{value:{authState:k,setAuthState:m}},n)};h.defaultProps={authStorageType:"cookie",authStorageName:"_auth_token",authTimeStorageName:"_auth_time",stateStorageName:"_auth_state",cookieSecure:!0};var s=i.Consumer,l=function(){return(l=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var T=function(){function e(e){if(this.context=e,!this.context.authState.isUsingRefreshToken)throw new Error("The app doesn't implement 'refreshToken' feature.\nSo you have to implement refresh token feature from 'AuthProvider' before using it.")}return e.prototype.getCurrentRefreshToken=function(){return{refreshToken:this.context.authState.refreshToken,refreshTokenExpireAt:this.context.authState.refreshTokenExpireAt}},e.prototype.getCurrentAuthState=function(){return{authToken:this.context.authState.authTokenType,authTokenType:this.context.authState.authToken,expireAt:this.context.authState.expireAt}},e.prototype.getCurrentUserState=function(){return this.context.authState.authState},e.prototype.updateRefreshToken=function(e,t){var n=new Date((new Date).getTime()+60*t*1e3);this.context.setAuthState((function(t){return l(l({},t),{refreshToken:e,refreshTokenExpireAt:n})}))},e.prototype.updateAuthState=function(e,t,n){var r={authToken:e};if(void 0!==t&&Object.assign(r,{authTokenType:t}),void 0!==n){var o=new Date((new Date).getTime()+60*n*1e3);Object.assign(r,{expireAt:o})}this.context.setAuthState((function(e){return l(l({},e),r)}))},e.prototype.updateUserState=function(e){this.context.setAuthState((function(t){return l(l({},t),{authState:e})}))},e}();e.AuthProvider=h,e.PrivateRoute=function(e){var n=t.useContext(i),o=e.component,a=e.loginPath,u=e.strict,h=e.sensitive,s=e.exact,T=e.path,f=e.location,c=e.render;return t.createElement(r.Route,{location:f,path:T,exact:s,sensitive:h,strict:u,render:function(e){return(null==n?void 0:n.authState.authToken)&&(null==n?void 0:n.authState.expireAt)&&(new Date(n.authState.expireAt)>new Date||(n.setAuthState((function(e){return l(l({},e),{authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null})})),0))?o?t.createElement(o,e):c?c(e):null:t.createElement(r.Redirect,{to:a})}})},e.useAuth=
/**

@@ -9,3 +23,3 @@ *@author Arkadip Bhattacharya <in2arkadipb13@gmail.com>

*/
function(){var e=t.useContext(i);return{authHeader:function(){return(null==e?void 0:e.authState)?e.authState.authTokenType+" "+e.authState.authToken:"Bearer "},isAuthenticated:function(){return!(!(null==e?void 0:e.authState.authToken)||!(null==e?void 0:e.authState.expireAt))&&(new Date(e.authState.expireAt)>new Date||(e.setAuthState({authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null}),!1))},authUser:function(){return e.authState.authState},signOut:function(){try{return!!(null==e?void 0:e.authState.authToken)&&(e.setAuthState((function(e){return l(l({},e),{authToken:null,authTokenType:null,expireAt:null,authState:null})})),console.log("RAJ :: Signing Out"),!0)}catch(e){return!1}},signIn:function(t){var n=t.token,r=t.tokenType,a=t.authState,o=t.expiresIn,u=new Date((new Date).getTime()+60*o*1e3);try{return!!e&&(e.setAuthState((function(e){return l(l({},e),{authToken:n,authTokenType:r,expireAt:u,authState:a})})),!0)}catch(e){return console.error(e),!1}}}}
function(){var e=t.useContext(i);return{authHeader:function(){return(null==e?void 0:e.authState)?e.authState.authTokenType+" "+e.authState.authToken:"Bearer "},isAuthenticated:function(){return!(!(null==e?void 0:e.authState.authToken)||!(null==e?void 0:e.authState.expireAt))&&(new Date(e.authState.expireAt)>new Date||(e.setAuthState((function(e){return l(l({},e),{authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null})})),!1))},authUser:function(){return e.authState.authState},signOut:function(){try{return!!(null==e?void 0:e.authState.authToken)&&(e.setAuthState((function(e){return l(l({},e),{authToken:null,authTokenType:null,refreshToken:null,refreshTokenExpireAt:null,expireAt:null,authState:null})})),console.log("RAJ :: Signing Out"),!0)}catch(e){return!1}},signIn:function(t){var n=t.token,r=t.tokenType,o=t.authState,a=t.expiresIn,u=t.refreshToken,i=t.refreshTokenExpireIn;if((u||i)&&!e.authState.isUsingRefreshToken)throw new Error("The app doesn't implement 'refreshToken' feature.\nSo you have to implement refresh token feature from 'AuthProvider' before using it.");var h=new Date((new Date).getTime()+60*a*1e3),s=i?new Date((new Date).getTime()+60*i*1e3):null;try{return!!e&&(e.setAuthState((function(e){return l(l({},e),{authToken:n,authTokenType:r,expireAt:h,authState:o,refreshToken:u||null,refreshTokenExpireAt:s})})),!0)}catch(e){return console.error(e),!1}}}}
/**

@@ -23,3 +37,3 @@ *@author Arkadip Bhattacharya <in2arkadipb13@gmail.com>

*/
function(){var e=t.useContext(i);return function(){return!(!(null==e?void 0:e.authState.authToken)||!(null==e?void 0:e.authState.expireAt))&&(new Date(e.authState.expireAt)>new Date||(e.setAuthState({authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null}),!1))}},e.useRefreshToken=function(){var e=t.useContext(i);return new c(e)},e.useSignIn=function(){var e=t.useContext(i);return function(t){var n=t.token,r=t.tokenType,a=t.authState,o=t.expiresIn,u=t.refreshToken,i=t.refreshTokenExpireIn,h=new Date((new Date).getTime()+60*o*1e3),s=i?new Date((new Date).getTime()+60*i*1e3):null;try{return!!e&&(e.setAuthState((function(e){return l(l({},e),{authToken:n,authTokenType:r,expireAt:h,authState:a,refreshToken:u||null,refreshTokenExpireAt:s})})),!0)}catch(e){return console.error(e),!1}}}
function(){var e=t.useContext(i);return function(){return!(!(null==e?void 0:e.authState.authToken)||!(null==e?void 0:e.authState.expireAt))&&(new Date(e.authState.expireAt)>new Date||(e.setAuthState((function(e){return l(l({},e),{authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null})})),!1))}},e.useRefreshToken=function(){var e=t.useContext(i);return new T(e)},e.useSignIn=function(){var e=t.useContext(i);return function(t){var n=t.token,r=t.tokenType,o=t.authState,a=t.expiresIn,u=t.refreshToken,i=t.refreshTokenExpireIn;if((u||i)&&!e.authState.isUsingRefreshToken)throw new Error("The app doesn't implement 'refreshToken' feature.\nSo you have to implement refresh token feature from 'AuthProvider' before using it.");var h=new Date((new Date).getTime()+60*a*1e3),s=i?new Date((new Date).getTime()+60*i*1e3):null;try{return!!e&&(e.setAuthState((function(e){return l(l({},e),{authToken:n,authTokenType:r,expireAt:h,authState:o,refreshToken:u||null,refreshTokenExpireAt:s})})),!0)}catch(e){return console.error(e),!1}}}
/**

@@ -50,2 +64,2 @@ *@author Arkadip Bhattacharya <in2arkadipb13@gmail.com>

*/
function(e){return function(n){return t.createElement(s,null,(function(r){return(null==r?void 0:r.authState.authToken)&&(null==r?void 0:r.authState.expireAt)?new Date(r.authState.expireAt)>new Date?t.createElement(e,l({},n,{isAuth:!0})):(r.setAuthState({authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null}),t.createElement(e,l({},n,{isAuth:!1}))):t.createElement(e,l({},n,{isAuth:!1}))}))}},e.withRefreshToken=function(e){return function(n){return t.createElement(s,null,(function(r){return t.createElement(e,l({},n,{refreshToken:new c(r)}))}))}},e.withSignIn=function(e){return function(n){return t.createElement(s,null,(function(r){return t.createElement(e,l({},n,{signIn:function(e){var t=e.token,n=e.tokenType,a=e.authState,o=e.expiresIn,u=e.refreshToken,i=e.refreshTokenExpireIn,h=new Date((new Date).getTime()+60*o*1e3),s=i?new Date((new Date).getTime()+60*i*1e3):null;try{return!!r&&(r.setAuthState((function(e){return l(l({},e),{authToken:t,authTokenType:n,expireAt:h,authState:a,refreshToken:u||null,refreshTokenExpireAt:s})})),!0)}catch(e){return console.error(e),!1}}}))}))}},e.withSignOut=function(e){return function(n){return t.createElement(s,null,(function(r){return t.createElement(e,l({},n,{signOut:function(){try{return!!(null==r?void 0:r.authState.authToken)&&(r.setAuthState((function(e){return l(l({},e),{authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null})})),!0)}catch(e){return!1}}}))}))}},Object.defineProperty(e,"__esModule",{value:!0})}));
function(e){return function(n){return t.createElement(s,null,(function(r){return(null==r?void 0:r.authState.authToken)&&(null==r?void 0:r.authState.expireAt)?new Date(r.authState.expireAt)>new Date?t.createElement(e,l({},n,{isAuth:!0})):(r.setAuthState((function(e){return l(l({},e),{authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null})})),t.createElement(e,l({},n,{isAuth:!1}))):t.createElement(e,l({},n,{isAuth:!1}))}))}},e.withRefreshToken=function(e){return function(n){return t.createElement(s,null,(function(r){return t.createElement(e,l({},n,{refreshToken:new T(r)}))}))}},e.withSignIn=function(e){return function(n){return t.createElement(s,null,(function(r){return t.createElement(e,l({},n,{signIn:function(e){var t=e.token,n=e.tokenType,o=e.authState,a=e.expiresIn,u=e.refreshToken,i=e.refreshTokenExpireIn;if((u||i)&&!r.authState.isUsingRefreshToken)throw new Error("The app doesn't implement 'refreshToken' feature.\nSo you have to implement refresh token feature from 'AuthProvider' before using it.");var h=new Date((new Date).getTime()+60*a*1e3),s=i?new Date((new Date).getTime()+60*i*1e3):null;try{return!!r&&(r.setAuthState((function(e){return l(l({},e),{authToken:t,authTokenType:n,expireAt:h,authState:o,refreshToken:u||null,refreshTokenExpireAt:s})})),!0)}catch(e){return console.error(e),!1}}}))}))}},e.withSignOut=function(e){return function(n){return t.createElement(s,null,(function(r){return t.createElement(e,l({},n,{signOut:function(){try{return!!(null==r?void 0:r.authState.authToken)&&(r.setAuthState((function(e){return l(l({},e),{authToken:null,authTokenType:null,expireAt:null,authState:null,refreshToken:null,refreshTokenExpireAt:null})})),!0)}catch(e){return!1}}}))}))}},Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -17,2 +17,3 @@ import { TokenInterface, TokenObjectParamsInterface } from './types';

private readonly refreshTokenTimeName;
private readonly isUsingRefreshToken;
/**

@@ -19,0 +20,0 @@ * TokenObject - Stores, retrieve and process tokens

@@ -6,2 +6,3 @@ import * as React from 'react';

expireAt: Date | null;
isUsingRefreshToken: boolean;
refreshToken: string | null;

@@ -8,0 +9,0 @@ refreshTokenExpireAt: Date | null;

{
"name": "react-auth-kit",
"version": "1.4.1-0",
"version": "1.4.2-0",
"description": "Authentication Library for React",

@@ -5,0 +5,0 @@ "source": "src/index.tsx",

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