@digigov/auth
Advanced tools
Comparing version 1.1.4-113e6661 to 1.1.4-2177f152
import React from 'react'; | ||
import { UserID, UserType, TokenType, AuthConfig, CodeType } from '@digigov/auth/'; | ||
export type ContextState = { | ||
export interface ContextState { | ||
authenticated?: boolean | null; | ||
@@ -14,7 +14,7 @@ id?: UserID | null | boolean; | ||
transformUserObject?: (user: object) => object; | ||
}; | ||
type ContextValue = { | ||
} | ||
interface ContextValue { | ||
state: ContextState; | ||
dispatch: (action: any) => void; | ||
}; | ||
} | ||
export declare const DEFAULT_STATE: { | ||
@@ -21,0 +21,0 @@ user: null; |
import React, { createContext, useReducer, useMemo } from "react"; | ||
import { authReducer } from "@digigov/auth/authReducer"; | ||
import { readSession } from "@digigov/auth/localSession"; | ||
import { authReducer } from "@digigov/auth/authReducer"; | ||
const DEFAULT_STATE = { | ||
@@ -5,0 +5,0 @@ user: null, |
@@ -37,4 +37,4 @@ var __create = Object.create; | ||
var import_react = __toESM(require("react")); | ||
var import_authReducer = require("@digigov/auth/authReducer"); | ||
var import_localSession = require("@digigov/auth/localSession"); | ||
var import_authReducer = require("@digigov/auth/authReducer"); | ||
const DEFAULT_STATE = { | ||
@@ -41,0 +41,0 @@ user: null, |
@@ -130,3 +130,4 @@ var __create = Object.create; | ||
} | ||
} catch (err) { | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
@@ -133,0 +134,0 @@ }, 500); |
@@ -51,3 +51,3 @@ var __create = Object.create; | ||
} else { | ||
isBrowser && window.close(); | ||
if (isBrowser) window.close(); | ||
} | ||
@@ -64,3 +64,3 @@ } else { | ||
if (!isUsedCode) { | ||
isBrowser && window.localStorage.removeItem("login-next"); | ||
if (isBrowser) window.localStorage.removeItem("login-next"); | ||
navigate(next || "/"); | ||
@@ -71,3 +71,3 @@ } else { | ||
} else { | ||
isBrowser && window.close(); | ||
if (isBrowser) window.close(); | ||
} | ||
@@ -78,6 +78,6 @@ } | ||
console.error(auth.error); | ||
isBrowser && window.localStorage.removeItem("login-next"); | ||
if (isBrowser) window.localStorage.removeItem("login-next"); | ||
navigate("/"); | ||
} else { | ||
isBrowser && window.close(); | ||
if (isBrowser) window.close(); | ||
} | ||
@@ -84,0 +84,0 @@ } |
@@ -92,3 +92,4 @@ import { useEffect, useMemo } from "react"; | ||
} | ||
} catch (err) { | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
@@ -95,0 +96,0 @@ }, 500); |
@@ -6,8 +6,8 @@ export type UserID = string | number; | ||
export declare const TOKEN_REVALIDATION_INTERVAL = 1; | ||
export type AuthConfig = { | ||
export interface AuthConfig { | ||
userDataURL?: string; | ||
loginURL?: string; | ||
tokenURL?: string; | ||
}; | ||
export type AuthState = { | ||
} | ||
export interface AuthState { | ||
authenticated: boolean; | ||
@@ -29,3 +29,3 @@ showWarning?: (...args: any[]) => void; | ||
config?: AuthConfig; | ||
}; | ||
} | ||
export declare function useAuth(): AuthState; | ||
@@ -32,0 +32,0 @@ export default useAuth; |
@@ -1,2 +0,2 @@ | ||
/** @license Digigov v1.1.4-113e6661 | ||
/** @license Digigov v1.1.4-2177f152 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the BSD-2-Clause license found in the |
{ | ||
"name": "@digigov/auth", | ||
"version": "1.1.4-113e6661", | ||
"version": "1.1.4-2177f152", | ||
"description": "@digigov authentication client", | ||
@@ -5,0 +5,0 @@ "author": "GRNET Developers <devs@lists.grnet.gr>", |
@@ -0,3 +1,3 @@ | ||
import { ContextState } from '@digigov/auth/AuthProvider'; | ||
import { updateSession } from '@digigov/auth/localSession'; | ||
import { ContextState } from '@digigov/auth/AuthProvider'; | ||
@@ -4,0 +4,0 @@ export function authReducer(state: ContextState, action): ContextState { |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-function-type */ | ||
import { useEffect, useMemo } from 'react'; | ||
@@ -108,3 +109,5 @@ import useAuth, { TokenType, UserType } from '@digigov/auth/'; | ||
} | ||
} catch (err) {} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}, 500); | ||
@@ -111,0 +114,0 @@ } |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-function-type */ | ||
import { useEffect, useContext } from 'react'; | ||
@@ -12,9 +13,9 @@ import { AuthContext } from '@digigov/auth/AuthProvider'; | ||
export type AuthConfig = { | ||
export interface AuthConfig { | ||
userDataURL?: string; | ||
loginURL?: string; | ||
tokenURL?: string; | ||
}; | ||
} | ||
export type AuthState = { | ||
export interface AuthState { | ||
authenticated: boolean; | ||
@@ -36,3 +37,3 @@ showWarning?: (...args) => void; | ||
config?: AuthConfig; | ||
}; | ||
} | ||
@@ -39,0 +40,0 @@ export function useAuth(): AuthState { |
@@ -18,3 +18,3 @@ import React, { useEffect, useState } from "react"; | ||
} else { | ||
isBrowser && window.close(); | ||
if (isBrowser) window.close(); | ||
} | ||
@@ -31,3 +31,3 @@ } else { | ||
if (!isUsedCode) { | ||
isBrowser && window.localStorage.removeItem("login-next"); | ||
if (isBrowser) window.localStorage.removeItem("login-next"); | ||
navigate(next || "/"); | ||
@@ -38,3 +38,3 @@ } else { | ||
} else { | ||
isBrowser && window.close(); | ||
if (isBrowser) window.close(); | ||
} | ||
@@ -45,6 +45,6 @@ } | ||
console.error(auth.error); | ||
isBrowser && window.localStorage.removeItem("login-next"); | ||
if (isBrowser) window.localStorage.removeItem("login-next"); | ||
navigate("/"); | ||
} else { | ||
isBrowser && window.close(); | ||
if (isBrowser) window.close(); | ||
} | ||
@@ -51,0 +51,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
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
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
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
Sorry, the diff of this file is not supported yet
113971
1863