react-auth-kit
Advanced tools
Comparing version 2.12.1 to 2.12.2-beta.1
import { __assign } from '../_virtual/_tslib.js'; | ||
import * as React from 'react'; | ||
import { AuthContextConsumer } from '../AuthContext.js'; | ||
import { doSignOut } from '../utils/reducers.js'; | ||
import { AuthKitError } from '../errors.js'; | ||
@@ -45,3 +44,2 @@ import { isAuthenticated } from '../utils/utils.js'; | ||
else { | ||
c.dispatch(doSignOut()); | ||
return React.createElement(Component, __assign({}, props, { isAuth: false })); | ||
@@ -48,0 +46,0 @@ } |
import * as React from 'react'; | ||
import AuthContext from '../AuthContext.js'; | ||
import { doSignOut } from '../utils/reducers.js'; | ||
import { AuthKitError } from '../errors.js'; | ||
@@ -39,3 +38,2 @@ import { isAuthenticated } from '../utils/utils.js'; | ||
if (!isAuthenticated(context.authState)) { | ||
context.dispatch(doSignOut()); | ||
return false; | ||
@@ -42,0 +40,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/*! react-auth-kit v2.12.1 | Apache-2.0 */ | ||
/*! react-auth-kit v2.12.2-beta.1 | 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,r,n){"use strict";function o(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=o(t),a=i.createContext(null),s=a.Consumer,u=function(e,t){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},u(e,t)}; | ||
@@ -105,3 +105,3 @@ /** | ||
*/ | ||
function(){var e=i.useContext(a);if(null===e)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return function(){return T(e.authState)?e.authState.userState:null}},e.useIsAuthenticated=function(){var e=i.useContext(a);if(null===e)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return function(){return!!T(e.authState)||(e.dispatch(k()),!1)}},e.useSignIn= | ||
function(){var e=i.useContext(a);if(null===e)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return function(){return T(e.authState)?e.authState.userState:null}},e.useIsAuthenticated=function(){var e=i.useContext(a);if(null===e)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return function(){return!!T(e.authState)}},e.useSignIn= | ||
/** | ||
@@ -185,3 +185,3 @@ *@author Arkadip Bhattacharya <in2arkadipb13@gmail.com> | ||
* limitations under the License. | ||
*/,e.withAuthUser=function(e){return function(t){return i.createElement(s,null,(function(r){if(null===r)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return r.authState.auth&&T(r.authState)?i.createElement(e,c({},t,{authState:r.authState.userState})):i.createElement(e,c({},t,{authState:null}))}))}},e.withIsAuthenticated=function(e){return function(t){return i.createElement(s,null,(function(r){if(null===r)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return r.authState.auth&&T(r.authState)?i.createElement(e,c({},t,{isAuth:!0})):(r.dispatch(k()),i.createElement(e,c({},t,{isAuth:!1})))}))}},e.withSignIn=function(e){return function(t){return i.createElement(s,null,(function(r){if(null===r)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return i.createElement(e,c({},t,{signIn:function(e){var t=e.token,n=e.tokenType,o=e.authState,i=e.expiresIn,a=e.refreshToken,s=e.refreshTokenExpireIn,u=new Date((new Date).getTime()+60*i*1e3);if(r.authState.isUsingRefreshToken){if(a&&s){var h=new Date((new Date).getTime()+60*s*1e3);return r.dispatch(m({auth:{token:t,type:n,expiresAt:u},userState:o||null,refresh:{token:a,expiresAt:h}})),!0}throw new p('Make sure you given "refreshToken" and "refreshTokenExpireIn" parameter')}if(a&&s)throw new p("The app doesn't implement 'refreshToken' feature.\n So you have to implement refresh token feature from 'AuthProvider' before using it.");return r.dispatch(m({auth:{token:t,type:n,expiresAt:u},userState:o||null,refresh:null})),!0}}))}))}},e.withSignOut=function(e){return function(t){return i.createElement(s,null,(function(r){if(null===r)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return i.createElement(e,c({},t,{signOut:function(){try{return!!r&&(r.dispatch(k()),!0)}catch(e){return!1}}}))}))}}})); | ||
*/,e.withAuthUser=function(e){return function(t){return i.createElement(s,null,(function(r){if(null===r)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return r.authState.auth&&T(r.authState)?i.createElement(e,c({},t,{authState:r.authState.userState})):i.createElement(e,c({},t,{authState:null}))}))}},e.withIsAuthenticated=function(e){return function(t){return i.createElement(s,null,(function(r){if(null===r)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return r.authState.auth&&T(r.authState)?i.createElement(e,c({},t,{isAuth:!0})):i.createElement(e,c({},t,{isAuth:!1}))}))}},e.withSignIn=function(e){return function(t){return i.createElement(s,null,(function(r){if(null===r)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return i.createElement(e,c({},t,{signIn:function(e){var t=e.token,n=e.tokenType,o=e.authState,i=e.expiresIn,a=e.refreshToken,s=e.refreshTokenExpireIn,u=new Date((new Date).getTime()+60*i*1e3);if(r.authState.isUsingRefreshToken){if(a&&s){var h=new Date((new Date).getTime()+60*s*1e3);return r.dispatch(m({auth:{token:t,type:n,expiresAt:u},userState:o||null,refresh:{token:a,expiresAt:h}})),!0}throw new p('Make sure you given "refreshToken" and "refreshTokenExpireIn" parameter')}if(a&&s)throw new p("The app doesn't implement 'refreshToken' feature.\n So you have to implement refresh token feature from 'AuthProvider' before using it.");return r.dispatch(m({auth:{token:t,type:n,expiresAt:u},userState:o||null,refresh:null})),!0}}))}))}},e.withSignOut=function(e){return function(t){return i.createElement(s,null,(function(r){if(null===r)throw new p("Auth Provider is missing. Please add the AuthProvider before Router");return i.createElement(e,c({},t,{signOut:function(){try{return!!r&&(r.dispatch(k()),!0)}catch(e){return!1}}}))}))}}})); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "react-auth-kit", | ||
"version": "2.12.1", | ||
"version": "2.12.2-beta.1", | ||
"description": "Authentication Library for React, which makes Token based auth very easy", | ||
@@ -93,3 +93,3 @@ "source": "src/index.tsx", | ||
"tslib": "2.5.0", | ||
"typedoc": "0.24.1", | ||
"typedoc": "0.24.2", | ||
"typescript": "5.0.4", | ||
@@ -96,0 +96,0 @@ "utility-types": "3.10.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
306239
2354
2