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.5-0 to 1.4.5

4

CHANGELOG.md

@@ -7,2 +7,6 @@ # Changelog

## [1.4.5] - 2021-02-10
### Fixed:
- Potential risk of duplicate tokens
## [1.4.4] - 2021-01-15

@@ -9,0 +13,0 @@ ### Fixed:

2

dist/index.umd.js

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

/*! react-auth-kit v1.4.5-0 | Apache-2.0 */
/*! react-auth-kit v1.4.5 | 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.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=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,{domain:this.cookieDomain,secure:this.cookieSecure}),a.default.remove(this.authTimeStorageName,{domain:this.cookieDomain,secure:this.cookieSecure}),a.default.remove(this.stateStorageName,{domain:this.cookieDomain,secure:this.cookieSecure}),this.isUsingRefreshToken&&this.refreshTokenName&&a.default.remove(this.refreshTokenName,{domain:this.cookieDomain,secure:this.cookieSecure}),this.isUsingRefreshToken&&this.refreshTokenTimeName&&a.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}(),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 c=new u({authTimeStorageName:a,authStorageType:r,authStorageName:o,refreshTokenName:s,cookieDomain:l,cookieSecure:T,stateStorageName:h}),f=t.useState(c.initialToken()),k=f[0],m=f[1];return t.useEffect((function(){c.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)};

@@ -3,0 +3,0 @@ /*! *****************************************************************************

{
"name": "react-auth-kit",
"version": "1.4.5-0",
"version": "1.4.5",
"description": "Authentication Library for React, which makes Token based auth very easy",

@@ -46,3 +46,3 @@ "source": "src/index.tsx",

"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-node-resolve": "^11.1.0",
"@types/jest": "^26.0.10",

@@ -54,5 +54,5 @@ "@types/js-cookie": "^2.2.6",

"@types/react-router-dom": "^5.1.5",
"@typescript-eslint/eslint-plugin": "^4.1.1",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.1.1",
"eslint": "^7.9.0",
"eslint": "^7.18.0",
"eslint-config-google": "^0.14.0",

@@ -64,3 +64,3 @@ "eslint-plugin-jest": "^24.0.0",

"react-dom": "^17.0.1",
"rollup": "^2.26.6",
"rollup": "^2.36.2",
"rollup-plugin-filesize": "^9.0.2",

@@ -72,3 +72,3 @@ "rollup-plugin-license": "^2.2.0",

"ts-jest": "^26.3.0",
"typedoc": "^0.20.12",
"typedoc": "^0.20.16",
"typescript": "^4.0.2",

@@ -75,0 +75,0 @@ "utility-types": "^3.10.0"

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