New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.6 to 1.4.7

16

CHANGELOG.md

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

# [1.4.6] - 2021-04-09
### Changed:
- Added GA in the docs
## [1.4.7] - 2021-04-11
###Changed:
- `AuthProvider` props. AuthProvider is now only using 4 props.
- Docs `/usage` is now `/integration`
- Docs updated Intro and installation page
- Better documentations added.
⚠️This release will break your code, as the AuthProvider props are changed. [Please refer to the docs](https://authkit.arkadip.me/integration)
## [1.4.6] - 2021-04-09
###Changed:
- Docs updated
## [1.4.5] - 2021-02-10

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

4

dist/AuthProvider.d.ts

@@ -9,8 +9,4 @@ import * as React from 'react';

* @param authStorageName
* @param authStorageType
* @param authTimeStorageName
* @param cookieDomain
* @param refreshTokenName
* @param cookieSecure
* @param stateStorageName
*

@@ -17,0 +13,0 @@ * @return Functional Component

@@ -389,8 +389,4 @@ 'use strict';

* @param authStorageName
* @param authStorageType
* @param authTimeStorageName
* @param cookieDomain
* @param refreshTokenName
* @param cookieSecure
* @param stateStorageName
*

@@ -400,4 +396,4 @@ * @return Functional Component

var AuthProvider = function (_a) {
var children = _a.children, authStorageType = _a.authStorageType, authStorageName = _a.authStorageName, authTimeStorageName = _a.authTimeStorageName, stateStorageName = _a.stateStorageName, refreshTokenName = _a.refreshTokenName, cookieDomain = _a.cookieDomain, cookieSecure = _a.cookieSecure;
if (authStorageType === 'cookie') {
var children = _a.children, authType = _a.authType, authName = _a.authName, refreshToken = _a.refreshToken, cookieDomain = _a.cookieDomain, cookieSecure = _a.cookieSecure;
if (authType === 'cookie') {
if (!cookieDomain) {

@@ -408,10 +404,11 @@ throw new Error('authStorageType \'cookie\' ' +

}
var refreshTokenName = refreshToken ? authName + "_refresh" : undefined;
var tokenObject = new TokenObject({
authTimeStorageName: authTimeStorageName,
authStorageType: authStorageType,
authStorageName: authStorageName,
authTimeStorageName: authName + "_time",
authStorageType: authType,
authStorageName: authName,
refreshTokenName: refreshTokenName,
cookieDomain: cookieDomain,
cookieSecure: cookieSecure,
stateStorageName: stateStorageName,
stateStorageName: authName + "_state",
});

@@ -425,7 +422,6 @@ var _b = React__namespace.useState(tokenObject.initialToken()), authState = _b[0], setAuthState = _b[1];

AuthProvider.defaultProps = {
authStorageType: 'cookie',
authStorageName: '_auth_token',
authTimeStorageName: '_auth_time',
stateStorageName: '_auth_state',
cookieSecure: true,
authType: 'cookie',
authName: '_auth',
cookieDomain: window.location.hostname,
cookieSecure: window.location.protocol === 'https:',
};

@@ -432,0 +428,0 @@ var AuthContextConsumer = AuthContext.Consumer;

@@ -360,8 +360,4 @@ import * as React from 'react';

* @param authStorageName
* @param authStorageType
* @param authTimeStorageName
* @param cookieDomain
* @param refreshTokenName
* @param cookieSecure
* @param stateStorageName
*

@@ -371,4 +367,4 @@ * @return Functional Component

var AuthProvider = function (_a) {
var children = _a.children, authStorageType = _a.authStorageType, authStorageName = _a.authStorageName, authTimeStorageName = _a.authTimeStorageName, stateStorageName = _a.stateStorageName, refreshTokenName = _a.refreshTokenName, cookieDomain = _a.cookieDomain, cookieSecure = _a.cookieSecure;
if (authStorageType === 'cookie') {
var children = _a.children, authType = _a.authType, authName = _a.authName, refreshToken = _a.refreshToken, cookieDomain = _a.cookieDomain, cookieSecure = _a.cookieSecure;
if (authType === 'cookie') {
if (!cookieDomain) {

@@ -379,10 +375,11 @@ throw new Error('authStorageType \'cookie\' ' +

}
var refreshTokenName = refreshToken ? authName + "_refresh" : undefined;
var tokenObject = new TokenObject({
authTimeStorageName: authTimeStorageName,
authStorageType: authStorageType,
authStorageName: authStorageName,
authTimeStorageName: authName + "_time",
authStorageType: authType,
authStorageName: authName,
refreshTokenName: refreshTokenName,
cookieDomain: cookieDomain,
cookieSecure: cookieSecure,
stateStorageName: stateStorageName,
stateStorageName: authName + "_state",
});

@@ -396,7 +393,6 @@ var _b = React.useState(tokenObject.initialToken()), authState = _b[0], setAuthState = _b[1];

AuthProvider.defaultProps = {
authStorageType: 'cookie',
authStorageName: '_auth_token',
authTimeStorageName: '_auth_time',
stateStorageName: '_auth_state',
cookieSecure: true,
authType: 'cookie',
authName: '_auth',
cookieDomain: window.location.hostname,
cookieSecure: window.location.protocol === 'https:',
};

@@ -403,0 +399,0 @@ var AuthContextConsumer = AuthContext.Consumer;

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

/*! react-auth-kit v1.4.6 | 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.authStorageType,r=e.authStorageName,o=e.authTimeStorageName,a=e.stateStorageName,i=e.refreshTokenName,l=e.cookieDomain,c=e.cookieSecure;if("cookie"===n&&!l)throw new Error("authStorageType 'cookie' requires 'cookieDomain' and 'cookieSecure' in AuthProvider");var f=new h({authTimeStorageName:o,authStorageType:n,authStorageName:r,refreshTokenName:i,cookieDomain:l,cookieSecure:c,stateStorageName:a}),T=u.useState(f.initialToken()),k=T[0],m=T[1];return u.useEffect((function(){f.syncTokens(k)}),[k]),u.createElement(s.Provider,{value:{authState:k,setAuthState:m}},t)};l.defaultProps={authStorageType:"cookie",authStorageName:"_auth_token",authTimeStorageName:"_auth_time",stateStorageName:"_auth_state",cookieSecure:!0};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)};
/*! react-auth-kit v1.4.7 | 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)};
/*! *****************************************************************************

@@ -4,0 +4,0 @@ Copyright (c) Microsoft Corporation.

@@ -32,4 +32,9 @@ import * as React from 'react';

}
export interface AuthProviderProps extends TokenObjectParamsInterface {
export interface AuthProviderProps {
authType: 'cookie' | 'localstorage';
authName: string;
refreshToken?: boolean;
cookieDomain?: string;
cookieSecure?: boolean;
children: React.ReactNode;
}
{
"name": "react-auth-kit",
"version": "1.4.6",
"version": "1.4.7",
"description": "Authentication Library for React, which makes Token based auth very easy",

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

@@ -17,3 +17,3 @@ <p align="center">

<a href="https://www.npmjs.com/package/react-auth-kit">
<img src="https://img.shields.io/npm/v/react-auth-kit.svg" alt="Test Suites">
<img src="https://img.shields.io/npm/v/react-auth-kit.svg?logo=npm" alt="Test Suites">
</a>

@@ -34,21 +34,9 @@ <a href="https://www.codacy.com/gh/react-auth-kit/react-auth-kit?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=react-auth-kit/react-auth-kit&amp;utm_campaign=Badge_Grade">

* 1.95 KB Gzipped
* Build for React
* Easy to Implementation
* Secure Client Side Authentication
* Highly typed and written in TypeScript
* Can be implemented using both [Higher Order Components](https://reactjs.org/docs/higher-order-components.html)
and [React Hooks](https://reactjs.org/docs/hooks-intro.html)
* 100% test coverage.
* 100% type annotated codebase.
* Zero hard dependencies.
* 📦 3.33 KB Gzipped
* ⚛️Build for React Js
* 🚀 Fast and easy to Implement
* 🛡️ Supports Json Web Token (JWT)
* 🔒 Secure Client Side Authentication
* ⌨️Highly typed and written in TypeScript
---
## Requirements
* Node Js 8.0+
* React Js 16.8+
* React-Router-Dom 3.0+
## Documentation

@@ -55,0 +43,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