react-auth-kit
Advanced tools
Comparing version 1.4.10 to 1.4.11
@@ -7,2 +7,9 @@ # Changelog | ||
## [1.4.11] - 2021-06-19 | ||
### Changed: | ||
- Updated dependencies | ||
### Fixed: | ||
- Deployment of docs | ||
## [1.4.10] - 2021-06-08 | ||
@@ -9,0 +16,0 @@ ### Added: |
@@ -1,2 +0,2 @@ | ||
/*! react-auth-kit v1.4.10 | Apache-2.0 */ | ||
/*! react-auth-kit v1.4.11 | 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}}function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var u=a(t),i=o(n),h=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.authStorageTypeName=this.authStorageName+"_type",this.isUsingRefreshToken=!!this.refreshTokenName,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=i.default.get(this.authStorageName),t=i.default.get(this.authStorageTypeName),n=i.default.get(this.authTimeStorageName),r=i.default.get(this.stateStorageName),o=this.isUsingRefreshToken&&null!=this.refreshTokenName?i.default.get(this.refreshTokenName):null,a=this.isUsingRefreshToken&&null!=this.refreshTokenTimeName?i.default.get(this.refreshTokenTimeName):null;return this.checkTokenExist(e,t,n,r,o,a)},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,a){i.default.set(this.authStorageName,e,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),i.default.set(this.authStorageTypeName,t,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),i.default.set(this.authTimeStorageName,r.toISOString(),{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),i.default.set(this.stateStorageName,a,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),this.isUsingRefreshToken&&this.refreshTokenName&&n&&i.default.set(this.refreshTokenName,n,{expires:r,domain:this.cookieDomain,secure:this.cookieSecure}),this.isUsingRefreshToken&&this.refreshTokenTimeName&&o&&i.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(){i.default.remove(this.authStorageName,{domain:this.cookieDomain,secure:this.cookieSecure}),i.default.remove(this.authTimeStorageName,{domain:this.cookieDomain,secure:this.cookieSecure}),i.default.remove(this.stateStorageName,{domain:this.cookieDomain,secure:this.cookieSecure}),this.isUsingRefreshToken&&this.refreshTokenName&&i.default.remove(this.refreshTokenName,{domain:this.cookieDomain,secure:this.cookieSecure}),this.isUsingRefreshToken&&this.refreshTokenTimeName&&i.default.remove(this.refreshTokenTimeName,{domain:this.cookieDomain,secure:this.cookieSecure})},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}(),s=u.createContext({authState:{authTokenType:null,authState:null,authToken:null,isUsingRefreshToken:!1,refreshToken:null,refreshTokenExpireAt:null,expireAt:null},setAuthState:function(){}}),l=function(e){var t=e.children,n=e.authType,r=e.authName,o=e.refreshToken,a=e.cookieDomain,i=e.cookieSecure;if("cookie"===n&&!a)throw new Error("authStorageType 'cookie' requires 'cookieDomain' and 'cookieSecure' in AuthProvider");var l=new h({authTimeStorageName:r+"_time",authStorageType:n,authStorageName:r,refreshTokenName:o?r+"_refresh":void 0,cookieDomain:a,cookieSecure:i,stateStorageName:r+"_state"}),c=u.useState(l.initialToken()),f=c[0],T=c[1];return u.useEffect((function(){l.syncTokens(f)}),[f]),u.createElement(s.Provider,{value:{authState:f,setAuthState:T}},t)};l.defaultProps={authType:"cookie",authName:"_auth",cookieDomain:window.location.hostname,cookieSecure:"https:"===window.location.protocol};var c=s.Consumer,f=function(){return(f=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)}; | ||
@@ -3,0 +3,0 @@ /*! ***************************************************************************** |
{ | ||
"name": "react-auth-kit", | ||
"version": "1.4.10", | ||
"version": "1.4.11", | ||
"description": "Authentication Library for React, which makes Token based auth very easy", | ||
@@ -25,2 +25,4 @@ "source": "src/index.tsx", | ||
"test:lint": "eslint src/**/*.ts src/**/*.tsx", | ||
"test:watch": "jest --watch", | ||
"test:coverage": "jest --coverage --colors", | ||
"fix": "eslint src/**/*.ts src/**/*.tsx --fix" | ||
@@ -48,18 +50,18 @@ }, | ||
"@rollup/plugin-node-resolve": "^13.0.0", | ||
"@types/jest": "^26.0.10", | ||
"@types/jest": "^26.0.23", | ||
"@types/js-cookie": "^2.2.6", | ||
"@types/node": "^15.0.1", | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"@types/node": "^15.12.2", | ||
"@types/react": "^17.0.11", | ||
"@types/react-dom": "^17.0.7", | ||
"@types/react-router-dom": "^5.1.5", | ||
"@typescript-eslint/eslint-plugin": "^4.14.0", | ||
"@typescript-eslint/parser": "^4.1.1", | ||
"eslint": "^7.18.0", | ||
"@typescript-eslint/eslint-plugin": "^4.27.0", | ||
"@typescript-eslint/parser": "^4.27.0", | ||
"eslint": "^7.28.0", | ||
"eslint-config-google": "^0.14.0", | ||
"eslint-plugin-jest": "^24.0.0", | ||
"eslint-plugin-react": "^7.20.6", | ||
"jest": "^26.4.2", | ||
"jest": "^27.0.4", | ||
"npm-run-all": "^4.1.5", | ||
"react-dom": "^17.0.1", | ||
"rollup": "^2.36.2", | ||
"rollup": "^2.52.1", | ||
"rollup-plugin-filesize": "^9.0.2", | ||
@@ -70,6 +72,6 @@ "rollup-plugin-license": "^2.2.0", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"ts-jest": "^26.3.0", | ||
"tslib": "^1.14.1", | ||
"typedoc": "^0.20.16", | ||
"typescript": "^4.3.2", | ||
"ts-jest": "^27.0.3", | ||
"tslib": "^2.3.0", | ||
"typedoc": "^0.21.0", | ||
"typescript": "^4.3.4", | ||
"utility-types": "^3.10.0" | ||
@@ -76,0 +78,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
278942
0