@digigov/auth
Advanced tools
Comparing version 0.0.1-fix-logout.5 to 0.0.1-fix-logout.6
@@ -13,2 +13,3 @@ import React from 'react'; | ||
navigate: (url: string) => void; | ||
userUpdatedAt?: number | null; | ||
}; | ||
@@ -15,0 +16,0 @@ declare type ContextValue = { |
@@ -26,3 +26,4 @@ "use strict"; | ||
error: null, | ||
code: null | ||
code: null, | ||
userUpdatedAt: Date.now() | ||
})); | ||
@@ -36,3 +37,4 @@ | ||
processing: false, | ||
error: null | ||
error: null, | ||
userUpdatedAt: null | ||
})); | ||
@@ -46,3 +48,4 @@ | ||
error: null, | ||
code: null | ||
code: null, | ||
userUpdatedAt: null | ||
})); | ||
@@ -58,3 +61,4 @@ | ||
code: null, | ||
error: null | ||
error: null, | ||
userUpdatedAt: null | ||
})); | ||
@@ -66,3 +70,4 @@ | ||
error: null, | ||
authenticated: false | ||
authenticated: false, | ||
userUpdatedAt: null | ||
})); | ||
@@ -84,3 +89,4 @@ | ||
token: null, | ||
id: false | ||
id: false, | ||
userUpdatedAt: null | ||
})); | ||
@@ -87,0 +93,0 @@ |
@@ -14,3 +14,4 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
error: null, | ||
code: null | ||
code: null, | ||
userUpdatedAt: Date.now() | ||
})); | ||
@@ -24,3 +25,4 @@ | ||
processing: false, | ||
error: null | ||
error: null, | ||
userUpdatedAt: null | ||
})); | ||
@@ -34,3 +36,4 @@ | ||
error: null, | ||
code: null | ||
code: null, | ||
userUpdatedAt: null | ||
})); | ||
@@ -46,3 +49,4 @@ | ||
code: null, | ||
error: null | ||
error: null, | ||
userUpdatedAt: null | ||
})); | ||
@@ -54,3 +58,4 @@ | ||
error: null, | ||
authenticated: false | ||
authenticated: false, | ||
userUpdatedAt: null | ||
})); | ||
@@ -72,3 +77,4 @@ | ||
token: null, | ||
id: false | ||
id: false, | ||
userUpdatedAt: null | ||
})); | ||
@@ -75,0 +81,0 @@ |
@@ -7,2 +7,4 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import { useDisableLoginNext } from '@digigov/auth/hooks'; | ||
export var TOKEN_REVALIDATION_INTERVAL = 3; // seconds | ||
export function useAuth() { | ||
@@ -191,2 +193,8 @@ var _useContext = useContext(AuthContext), | ||
function revalidateToken(onError) { | ||
if (state.userUpdatedAt && (Date.now() - state.userUpdatedAt) / 1000 < TOKEN_REVALIDATION_INTERVAL) { | ||
// check if a revalidation was asked during the specified interval | ||
// and stop the process | ||
return; | ||
} | ||
handleToken(state, dispatch, onError); | ||
@@ -193,0 +201,0 @@ } |
@@ -14,3 +14,4 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
error: null, | ||
code: null | ||
code: null, | ||
userUpdatedAt: Date.now() | ||
})); | ||
@@ -24,3 +25,4 @@ | ||
processing: false, | ||
error: null | ||
error: null, | ||
userUpdatedAt: null | ||
})); | ||
@@ -34,3 +36,4 @@ | ||
error: null, | ||
code: null | ||
code: null, | ||
userUpdatedAt: null | ||
})); | ||
@@ -46,3 +49,4 @@ | ||
code: null, | ||
error: null | ||
error: null, | ||
userUpdatedAt: null | ||
})); | ||
@@ -54,3 +58,4 @@ | ||
error: null, | ||
authenticated: false | ||
authenticated: false, | ||
userUpdatedAt: null | ||
})); | ||
@@ -72,3 +77,4 @@ | ||
token: null, | ||
id: false | ||
id: false, | ||
userUpdatedAt: null | ||
})); | ||
@@ -75,0 +81,0 @@ |
@@ -1,2 +0,2 @@ | ||
/** @license Digigov v0.0.1-fix-logout.5+8de0d91 | ||
/** @license Digigov v0.0.1-fix-logout.6+51b1467 | ||
* | ||
@@ -12,2 +12,4 @@ * This source code is licensed under the MIT license found in the | ||
import { useDisableLoginNext } from '@digigov/auth/hooks'; | ||
export var TOKEN_REVALIDATION_INTERVAL = 3; // seconds | ||
export function useAuth() { | ||
@@ -196,2 +198,8 @@ var _useContext = useContext(AuthContext), | ||
function revalidateToken(onError) { | ||
if (state.userUpdatedAt && (Date.now() - state.userUpdatedAt) / 1000 < TOKEN_REVALIDATION_INTERVAL) { | ||
// check if a revalidation was asked during the specified interval | ||
// and stop the process | ||
return; | ||
} | ||
handleToken(state, dispatch, onError); | ||
@@ -198,0 +206,0 @@ } |
@@ -5,2 +5,3 @@ export declare type UserID = string | number; | ||
export declare type CodeType = string | Record<string, any> | null; | ||
export declare const TOKEN_REVALIDATION_INTERVAL = 3; | ||
export declare type AuthConfig = { | ||
@@ -7,0 +8,0 @@ userDataURL?: string; |
14
index.js
@@ -1,2 +0,2 @@ | ||
/** @license Digigov v0.0.1-fix-logout.5+8de0d91 | ||
/** @license Digigov v0.0.1-fix-logout.6+51b1467 | ||
* | ||
@@ -14,6 +14,7 @@ * This source code is licensed under the MIT license found in the | ||
var _exportNames = { | ||
TOKEN_REVALIDATION_INTERVAL: true, | ||
useAuth: true | ||
}; | ||
exports.useAuth = useAuth; | ||
exports["default"] = void 0; | ||
exports["default"] = exports.TOKEN_REVALIDATION_INTERVAL = void 0; | ||
@@ -66,3 +67,6 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
}); | ||
var TOKEN_REVALIDATION_INTERVAL = 3; // seconds | ||
exports.TOKEN_REVALIDATION_INTERVAL = TOKEN_REVALIDATION_INTERVAL; | ||
function useAuth() { | ||
@@ -251,2 +255,8 @@ var _useContext = (0, _react.useContext)(_AuthProvider.AuthContext), | ||
function revalidateToken(onError) { | ||
if (state.userUpdatedAt && (Date.now() - state.userUpdatedAt) / 1000 < TOKEN_REVALIDATION_INTERVAL) { | ||
// check if a revalidation was asked during the specified interval | ||
// and stop the process | ||
return; | ||
} | ||
handleToken(state, dispatch, onError); | ||
@@ -253,0 +263,0 @@ } |
{ | ||
"name": "@digigov/auth", | ||
"version": "0.0.1-fix-logout.5+8de0d91", | ||
"version": "0.0.1-fix-logout.6+51b1467", | ||
"description": "@digigov authentication client", | ||
@@ -20,5 +20,5 @@ "author": "GRNET Developers <devs@lists.grnet.gr>", | ||
}, | ||
"gitHead": "8de0d912a8632d3bfbb4e80c16688cddc603466e", | ||
"gitHead": "51b1467de994718787dd259d07a74f465ad1ed0d", | ||
"private": false, | ||
"typings": "./index.d.ts" | ||
} |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
93363
2723