@databiosphere/findable-ui 50.8.0 → 51.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth/constants/auth.d.ts +5 -0
- package/lib/{providers/authentication/auth/constants.js → auth/constants/auth.js} +4 -1
- package/lib/auth/constants/authentication.d.ts +5 -0
- package/lib/{providers/authentication/authentication/constants.js → auth/constants/authentication.js} +4 -1
- package/lib/auth/constants/credentials.d.ts +5 -0
- package/lib/{providers/authentication/credentials/constants.js → auth/constants/credentials.js} +3 -0
- package/lib/auth/constants/token.d.ts +5 -0
- package/lib/{providers/authentication/token/constants.js → auth/constants/token.js} +3 -0
- package/lib/{providers/authentication/auth/context.d.ts → auth/contexts/auth.d.ts} +4 -1
- package/lib/{providers/authentication/auth/context.js → auth/contexts/auth.js} +4 -1
- package/lib/auth/contexts/authentication.d.ts +5 -0
- package/lib/{providers/authentication/authentication/context.js → auth/contexts/authentication.js} +4 -1
- package/lib/auth/contexts/credentials.d.ts +5 -0
- package/lib/{providers/authentication/credentials/context.js → auth/contexts/credentials.js} +4 -1
- package/lib/{providers/authentication/auth/dispatch.d.ts → auth/dispatch/auth.d.ts} +2 -2
- package/lib/{providers/authentication/auth/dispatch.js → auth/dispatch/auth.js} +2 -2
- package/lib/{providers/authentication/authentication/dispatch.d.ts → auth/dispatch/authentication.d.ts} +2 -2
- package/lib/{providers/authentication/authentication/dispatch.js → auth/dispatch/authentication.js} +2 -2
- package/lib/auth/dispatch/credentials.d.ts +12 -0
- package/lib/{providers/authentication/credentials/dispatch.js → auth/dispatch/credentials.js} +3 -3
- package/lib/{providers/authentication/token/dispatch.d.ts → auth/dispatch/token.d.ts} +3 -3
- package/lib/{providers/authentication/token/dispatch.js → auth/dispatch/token.js} +3 -3
- package/lib/{providers/authentication/auth/hook.d.ts → auth/hooks/useAuth.d.ts} +1 -1
- package/lib/{providers/authentication/auth/hook.js → auth/hooks/useAuth.js} +1 -1
- package/lib/auth/hooks/useAuthReducer.d.ts +7 -0
- package/lib/auth/hooks/useAuthReducer.js +13 -0
- package/lib/{providers/authentication/authentication/hook.d.ts → auth/hooks/useAuthentication.d.ts} +1 -1
- package/lib/{providers/authentication/authentication/hook.js → auth/hooks/useAuthentication.js} +1 -1
- package/lib/auth/hooks/useAuthenticationReducer.d.ts +7 -0
- package/lib/auth/hooks/useAuthenticationReducer.js +13 -0
- package/lib/{providers/authentication/credentials/hook.d.ts → auth/hooks/useCredentials.d.ts} +1 -1
- package/lib/{providers/authentication/credentials/hook.js → auth/hooks/useCredentials.js} +1 -1
- package/lib/auth/hooks/useCredentialsReducer.d.ts +6 -0
- package/lib/{hooks/authentication/credentials → auth/hooks}/useCredentialsReducer.js +6 -2
- package/lib/{providers/authentication/auth/reducer.d.ts → auth/reducers/auth.d.ts} +1 -1
- package/lib/{providers/authentication/auth/reducer.js → auth/reducers/auth.js} +13 -2
- package/lib/{providers/authentication/authentication/reducer.d.ts → auth/reducers/authentication.d.ts} +1 -1
- package/lib/{providers/authentication/authentication/reducer.js → auth/reducers/authentication.js} +13 -2
- package/lib/{providers/authentication/credentials/reducer.d.ts → auth/reducers/credentials.d.ts} +1 -1
- package/lib/{providers/authentication/credentials/reducer.js → auth/reducers/credentials.js} +14 -3
- package/lib/{providers/authentication/token/reducer.d.ts → auth/reducers/token.d.ts} +1 -1
- package/lib/{providers/authentication/token/reducer.js → auth/reducers/token.js} +2 -2
- package/lib/{providers/authentication/auth/types.d.ts → auth/types/auth.d.ts} +41 -5
- package/lib/{providers/authentication/auth/types.js → auth/types/auth.js} +6 -0
- package/lib/{providers/authentication/authentication/types.d.ts → auth/types/authentication.d.ts} +46 -4
- package/lib/{providers/authentication/authentication/types.js → auth/types/authentication.js} +6 -0
- package/lib/auth/types/common.d.ts +4 -0
- package/lib/{providers/authentication/credentials/types.d.ts → auth/types/credentials.d.ts} +31 -4
- package/lib/{providers/authentication/credentials/types.js → auth/types/credentials.js} +3 -0
- package/lib/auth/types/loginProvider.d.ts +11 -0
- package/lib/{providers/authentication/token/types.d.ts → auth/types/token.d.ts} +29 -5
- package/lib/{providers/authentication/token/types.js → auth/types/token.js} +3 -0
- package/lib/components/ComponentCreator/ComponentCreator.js +1 -1
- package/lib/components/Export/components/ExportToTerra/components/TerraSetUpForm/components/FormStep/components/AcceptTerraTOS/acceptTerraTOS.js +1 -1
- package/lib/components/Export/components/ExportToTerra/components/TerraSetUpForm/terraSetUpForm.js +2 -2
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.d.ts +1 -1
- package/lib/components/Layout/components/Header/components/Content/components/Actions/components/Authentication/components/AuthenticationMenu/authenticationMenu.js +1 -1
- package/lib/components/Login/components/Buttons/buttons.d.ts +1 -1
- package/lib/components/Login/components/Buttons/buttons.js +1 -1
- package/lib/components/Login/components/Buttons/types.d.ts +5 -5
- package/lib/components/Login/hooks/useUserLogin/types.d.ts +1 -1
- package/lib/components/Login/hooks/useUserLogin/useUserLogin.js +1 -1
- package/lib/components/Login/login.d.ts +1 -1
- package/lib/components/Login/login.js +1 -1
- package/lib/components/Login/types.d.ts +3 -4
- package/lib/config/entities.d.ts +3 -3
- package/lib/google/config.d.ts +7 -0
- package/lib/google/config.js +14 -0
- package/lib/google/constants.d.ts +16 -0
- package/lib/google/constants.js +24 -0
- package/lib/google/hooks/useGoogleSignInService.d.ts +8 -0
- package/lib/{providers/googleSignInAuthentication → google}/hooks/useGoogleSignInService.js +7 -2
- package/lib/{hooks/authentication/token → google/hooks}/useTokenReducer.d.ts +2 -1
- package/lib/{hooks/authentication/token → google/hooks}/useTokenReducer.js +3 -2
- package/lib/google/provider.d.ts +11 -0
- package/lib/{providers/googleSignInAuthentication → google}/provider.js +19 -11
- package/lib/google/service.d.ts +18 -0
- package/lib/{providers/googleSignInAuthentication/service → google}/service.js +20 -9
- package/lib/google/session-controller.d.ts +11 -0
- package/lib/{components/Authentication/components/SessionController/components/GoogleSessionController/SessionController.js → google/session-controller.js} +14 -6
- package/lib/google/types.d.ts +58 -0
- package/lib/{providers/authentication/authentication/utils.d.ts → google/utils/auth.d.ts} +6 -0
- package/lib/{providers/authentication/authentication/utils.js → google/utils/auth.js} +10 -0
- package/lib/{providers/googleSignInAuthentication/profile/utils.d.ts → google/utils/profile.d.ts} +2 -2
- package/lib/{providers/googleSignInAuthentication/profile/utils.js → google/utils/profile.js} +1 -1
- package/lib/hooks/authentication/profile/types.d.ts +1 -1
- package/lib/hooks/authentication/profile/useProfile.js +3 -3
- package/lib/hooks/authentication/providers/types.d.ts +1 -1
- package/lib/hooks/authentication/session/useSessionActive.d.ts +2 -2
- package/lib/hooks/authentication/session/useSessionActive.js +2 -2
- package/lib/hooks/authentication/terra/useAuthenticationForm.js +1 -1
- package/lib/hooks/authentication/terra/useAuthenticationNIHExpiry.js +2 -2
- package/lib/hooks/authentication/token/types.d.ts +1 -1
- package/lib/hooks/authentication/token/useToken.js +1 -1
- package/lib/{components/Authentication/components/SessionController/components/NextSessionController → nextauth}/constants.d.ts +8 -2
- package/lib/{components/Authentication/components/SessionController/components/NextSessionController → nextauth}/constants.js +8 -2
- package/lib/nextauth/hooks/useNextAuthService.d.ts +6 -0
- package/lib/{providers/nextAuthAuthentication → nextauth}/hooks/useNextAuthService.js +7 -3
- package/lib/nextauth/provider.d.ts +12 -0
- package/lib/{providers/nextAuthAuthentication → nextauth}/provider.js +16 -7
- package/lib/nextauth/service.d.ts +20 -0
- package/lib/{providers/nextAuthAuthentication/service → nextauth}/service.js +14 -0
- package/lib/nextauth/session-controller.d.ts +10 -0
- package/lib/{components/Authentication/components/SessionController/components/NextSessionController/SessionController.js → nextauth/session-controller.js} +11 -4
- package/lib/{providers/nextAuthAuthentication → nextauth}/types.d.ts +9 -0
- package/lib/{components/Authentication/components/SessionController/components/NextSessionController → nextauth}/utils.d.ts +2 -2
- package/lib/{components/Authentication/components/SessionController/components/NextSessionController → nextauth}/utils.js +2 -2
- package/lib/providers/loginGuard/provider.js +1 -1
- package/lib/terra/constants.d.ts +28 -0
- package/lib/{providers/authentication/terra/hooks/common → terra}/constants.js +16 -1
- package/lib/terra/context.d.ts +5 -0
- package/lib/{providers/authentication/terra → terra}/context.js +4 -1
- package/lib/{providers/authentication/terra → terra}/hooks/useFetchProfiles.d.ts +12 -4
- package/lib/{providers/authentication/terra → terra}/hooks/useFetchProfiles.js +9 -4
- package/lib/{providers/authentication/terra → terra}/hooks/useFetchTerraNIHProfile.d.ts +2 -6
- package/lib/{providers/authentication/terra → terra}/hooks/useFetchTerraNIHProfile.js +4 -5
- package/lib/terra/hooks/useFetchTerraProfile.d.ts +10 -0
- package/lib/{providers/authentication/terra → terra}/hooks/useFetchTerraProfile.js +4 -5
- package/lib/{providers/authentication/terra → terra}/hooks/useFetchTerraTermsOfService.d.ts +2 -7
- package/lib/{providers/authentication/terra → terra}/hooks/useFetchTerraTermsOfService.js +4 -5
- package/lib/{providers/authentication/terra/hook.d.ts → terra/hooks/useTerraProfile.d.ts} +1 -1
- package/lib/{providers/authentication/terra/hook.js → terra/hooks/useTerraProfile.js} +1 -1
- package/lib/terra/provider.d.ts +10 -0
- package/lib/{providers/authentication/terra → terra}/provider.js +13 -6
- package/lib/terra/types/common.d.ts +50 -0
- package/lib/terra/types/common.js +19 -0
- package/lib/terra/types/context.d.ts +12 -0
- package/lib/terra/types/terra-nih.d.ts +8 -0
- package/lib/{providers/authentication/terra/hooks/useFetchTerraProfile.d.ts → terra/types/terra-profile.d.ts} +9 -8
- package/lib/terra/types/terra-tos.d.ts +9 -0
- package/lib/terra/types/terra-tos.js +1 -0
- package/lib/terra/utils.d.ts +47 -0
- package/lib/{providers/authentication/terra → terra}/utils.js +45 -2
- package/lib/views/LoginView/loginView.d.ts +2 -2
- package/package.json +15 -1
- package/lib/components/Authentication/components/SessionController/components/GoogleSessionController/SessionController.d.ts +0 -3
- package/lib/components/Authentication/components/SessionController/components/GoogleSessionController/types.d.ts +0 -6
- package/lib/components/Authentication/components/SessionController/components/NextSessionController/SessionController.d.ts +0 -3
- package/lib/components/Authentication/components/SessionController/components/NextSessionController/types.d.ts +0 -4
- package/lib/hooks/authentication/auth/useAuthReducer.d.ts +0 -2
- package/lib/hooks/authentication/auth/useAuthReducer.js +0 -8
- package/lib/hooks/authentication/authentication/useAuthenticationReducer.d.ts +0 -2
- package/lib/hooks/authentication/authentication/useAuthenticationReducer.js +0 -8
- package/lib/hooks/authentication/credentials/useCredentialsReducer.d.ts +0 -2
- package/lib/providers/authentication/auth/actions.d.ts +0 -8
- package/lib/providers/authentication/auth/actions.js +0 -12
- package/lib/providers/authentication/auth/constants.d.ts +0 -2
- package/lib/providers/authentication/authentication/actions.d.ts +0 -8
- package/lib/providers/authentication/authentication/actions.js +0 -12
- package/lib/providers/authentication/authentication/constants.d.ts +0 -2
- package/lib/providers/authentication/authentication/context.d.ts +0 -2
- package/lib/providers/authentication/common/types.d.ts +0 -1
- package/lib/providers/authentication/credentials/actions.d.ts +0 -8
- package/lib/providers/authentication/credentials/actions.js +0 -12
- package/lib/providers/authentication/credentials/constants.d.ts +0 -2
- package/lib/providers/authentication/credentials/context.d.ts +0 -2
- package/lib/providers/authentication/credentials/dispatch.d.ts +0 -12
- package/lib/providers/authentication/terra/context.d.ts +0 -2
- package/lib/providers/authentication/terra/hooks/common/constants.d.ts +0 -6
- package/lib/providers/authentication/terra/hooks/common/entities.d.ts +0 -21
- package/lib/providers/authentication/terra/hooks/common/entities.js +0 -7
- package/lib/providers/authentication/terra/hooks/common/utils.d.ts +0 -15
- package/lib/providers/authentication/terra/hooks/common/utils.js +0 -25
- package/lib/providers/authentication/terra/hooks/utils.d.ts +0 -16
- package/lib/providers/authentication/terra/hooks/utils.js +0 -19
- package/lib/providers/authentication/terra/provider.d.ts +0 -3
- package/lib/providers/authentication/terra/types.d.ts +0 -20
- package/lib/providers/authentication/terra/types.js +0 -6
- package/lib/providers/authentication/terra/utils.d.ts +0 -19
- package/lib/providers/authentication/token/constants.d.ts +0 -2
- package/lib/providers/googleSignInAuthentication/common/types.d.ts +0 -17
- package/lib/providers/googleSignInAuthentication/constants.d.ts +0 -4
- package/lib/providers/googleSignInAuthentication/constants.js +0 -12
- package/lib/providers/googleSignInAuthentication/hooks/useGoogleSignInService.d.ts +0 -3
- package/lib/providers/googleSignInAuthentication/profile/types.d.ts +0 -14
- package/lib/providers/googleSignInAuthentication/provider.d.ts +0 -3
- package/lib/providers/googleSignInAuthentication/service/constants.d.ts +0 -4
- package/lib/providers/googleSignInAuthentication/service/constants.js +0 -9
- package/lib/providers/googleSignInAuthentication/service/service.d.ts +0 -6
- package/lib/providers/googleSignInAuthentication/types.d.ts +0 -6
- package/lib/providers/nextAuthAuthentication/hooks/useNextAuthService.d.ts +0 -2
- package/lib/providers/nextAuthAuthentication/provider.d.ts +0 -3
- package/lib/providers/nextAuthAuthentication/service/service.d.ts +0 -6
- /package/lib/{hooks/authentication/session → auth/hooks}/useSessionIdleTimer.d.ts +0 -0
- /package/lib/{hooks/authentication/session → auth/hooks}/useSessionIdleTimer.js +0 -0
- /package/lib/{components/Authentication/components/SessionController/components/GoogleSessionController/types.js → auth/types/common.js} +0 -0
- /package/lib/{components/Authentication/components/SessionController/components/NextSessionController/types.js → auth/types/loginProvider.js} +0 -0
- /package/lib/{providers/authentication/common/utils.d.ts → auth/utils/initializer.d.ts} +0 -0
- /package/lib/{providers/authentication/common/utils.js → auth/utils/initializer.js} +0 -0
- /package/lib/{providers/authentication/common → google}/types.js +0 -0
- /package/lib/{providers/googleSignInAuthentication/common → nextauth}/types.js +0 -0
- /package/lib/{providers/googleSignInAuthentication/profile/types.js → terra/types/context.js} +0 -0
- /package/lib/{providers/googleSignInAuthentication/types.js → terra/types/terra-nih.js} +0 -0
- /package/lib/{providers/nextAuthAuthentication/types.js → terra/types/terra-profile.js} +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { AUTHENTICATION_STATUS } from "
|
|
1
|
+
import { AUTHENTICATION_STATUS, } from "../types/authentication";
|
|
2
|
+
/**
|
|
3
|
+
* Default authentication state.
|
|
4
|
+
*/
|
|
2
5
|
export const DEFAULT_AUTHENTICATION_STATE = {
|
|
3
6
|
profile: undefined,
|
|
4
7
|
status: AUTHENTICATION_STATUS.PENDING,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
|
-
import { DEFAULT_AUTH_STATE } from "
|
|
2
|
+
import { DEFAULT_AUTH_STATE } from "../constants/auth";
|
|
3
|
+
/**
|
|
4
|
+
* Auth context.
|
|
5
|
+
*/
|
|
3
6
|
export const AuthContext = createContext({
|
|
4
7
|
authDispatch: null,
|
|
5
8
|
authState: DEFAULT_AUTH_STATE,
|
package/lib/{providers/authentication/authentication/context.js → auth/contexts/authentication.js}
RENAMED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
|
-
import { DEFAULT_AUTHENTICATION_STATE } from "
|
|
2
|
+
import { DEFAULT_AUTHENTICATION_STATE } from "../constants/authentication";
|
|
3
|
+
/**
|
|
4
|
+
* Authentication context.
|
|
5
|
+
*/
|
|
3
6
|
export const AuthenticationContext = createContext({
|
|
4
7
|
authenticationDispatch: null,
|
|
5
8
|
authenticationState: DEFAULT_AUTHENTICATION_STATE,
|
package/lib/{providers/authentication/credentials/context.js → auth/contexts/credentials.js}
RENAMED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
|
-
import { DEFAULT_CREDENTIALS_STATE } from "
|
|
2
|
+
import { DEFAULT_CREDENTIALS_STATE } from "../constants/credentials";
|
|
3
|
+
/**
|
|
4
|
+
* Credentials context.
|
|
5
|
+
*/
|
|
3
6
|
export const CredentialsContext = createContext({
|
|
4
7
|
credentialsDispatch: null,
|
|
5
8
|
credentialsState: DEFAULT_CREDENTIALS_STATE,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthResetStateAction, RequestAuthAction, UpdateAuthStateAction, UpdateAuthStatePayload } from "../types/auth";
|
|
2
2
|
/**
|
|
3
3
|
* Auth is complete.
|
|
4
4
|
* @param payload - Payload.
|
|
@@ -14,7 +14,7 @@ export declare function requestAuth(): RequestAuthAction;
|
|
|
14
14
|
* Reset state action.
|
|
15
15
|
* @returns state.
|
|
16
16
|
*/
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function resetAuthState(): AuthResetStateAction;
|
|
18
18
|
/**
|
|
19
19
|
* Update auth state action.
|
|
20
20
|
* @param payload - Payload.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AUTH_STATUS, AuthActionKind, } from "
|
|
1
|
+
import { AUTH_STATUS, AuthActionKind, } from "../types/auth";
|
|
2
2
|
/**
|
|
3
3
|
* Auth is complete.
|
|
4
4
|
* @param payload - Payload.
|
|
@@ -24,7 +24,7 @@ export function requestAuth() {
|
|
|
24
24
|
* Reset state action.
|
|
25
25
|
* @returns state.
|
|
26
26
|
*/
|
|
27
|
-
export function
|
|
27
|
+
export function resetAuthState() {
|
|
28
28
|
return {
|
|
29
29
|
payload: undefined,
|
|
30
30
|
type: AuthActionKind.ResetState,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthenticationResetStateAction, RequestAuthenticationAction, UpdateAuthenticationAction, UpdateAuthenticationPayload } from "../types/authentication";
|
|
2
2
|
/**
|
|
3
3
|
* Authentication is complete.
|
|
4
4
|
* @returns Action.
|
|
@@ -13,7 +13,7 @@ export declare function requestAuthentication(): RequestAuthenticationAction;
|
|
|
13
13
|
* Reset authentication action.
|
|
14
14
|
* @returns Action.
|
|
15
15
|
*/
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function resetAuthenticationState(): AuthenticationResetStateAction;
|
|
17
17
|
/**
|
|
18
18
|
* Update authentication action.
|
|
19
19
|
* @param payload - Payload.
|
package/lib/{providers/authentication/authentication/dispatch.js → auth/dispatch/authentication.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AUTHENTICATION_STATUS, AuthenticationActionKind, } from "
|
|
1
|
+
import { AUTHENTICATION_STATUS, AuthenticationActionKind, } from "../types/authentication";
|
|
2
2
|
/**
|
|
3
3
|
* Authentication is complete.
|
|
4
4
|
* @returns Action.
|
|
@@ -23,7 +23,7 @@ export function requestAuthentication() {
|
|
|
23
23
|
* Reset authentication action.
|
|
24
24
|
* @returns Action.
|
|
25
25
|
*/
|
|
26
|
-
export function
|
|
26
|
+
export function resetAuthenticationState() {
|
|
27
27
|
return {
|
|
28
28
|
payload: undefined,
|
|
29
29
|
type: AuthenticationActionKind.ResetState,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CredentialsResetStateAction, UpdateCredentialsAction, UpdateCredentialsPayload } from "../types/credentials";
|
|
2
|
+
/**
|
|
3
|
+
* Reset credentials state action.
|
|
4
|
+
* @returns Action.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resetCredentialsState(): CredentialsResetStateAction;
|
|
7
|
+
/**
|
|
8
|
+
* Update credentials action.
|
|
9
|
+
* @param payload - Payload.
|
|
10
|
+
* @returns Action.
|
|
11
|
+
*/
|
|
12
|
+
export declare function updateCredentials(payload: UpdateCredentialsPayload): UpdateCredentialsAction;
|
package/lib/{providers/authentication/credentials/dispatch.js → auth/dispatch/credentials.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CredentialsActionKind, } from "
|
|
1
|
+
import { CredentialsActionKind, } from "../types/credentials";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Reset credentials state action.
|
|
4
4
|
* @returns Action.
|
|
5
5
|
*/
|
|
6
|
-
export function
|
|
6
|
+
export function resetCredentialsState() {
|
|
7
7
|
return {
|
|
8
8
|
payload: undefined,
|
|
9
9
|
type: CredentialsActionKind.ResetState,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TokenResetStateAction, UpdateTokenAction, UpdateTokenPayload } from "../types/token";
|
|
2
2
|
/**
|
|
3
|
-
* Reset state action.
|
|
3
|
+
* Reset token state action.
|
|
4
4
|
* @returns Action.
|
|
5
5
|
*/
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function resetTokenState(): TokenResetStateAction;
|
|
7
7
|
/**
|
|
8
8
|
* Update token action.
|
|
9
9
|
* @param payload - Payload.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TokenActionKind, } from "
|
|
1
|
+
import { TokenActionKind, } from "../types/token";
|
|
2
2
|
/**
|
|
3
|
-
* Reset state action.
|
|
3
|
+
* Reset token state action.
|
|
4
4
|
* @returns Action.
|
|
5
5
|
*/
|
|
6
|
-
export function
|
|
6
|
+
export function resetTokenState() {
|
|
7
7
|
return {
|
|
8
8
|
payload: undefined,
|
|
9
9
|
type: TokenActionKind.ResetState,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AuthContextProps, AuthState } from "../types/auth";
|
|
2
|
+
/**
|
|
3
|
+
* Auth reducer hook.
|
|
4
|
+
* @param initialState - Initial state.
|
|
5
|
+
* @returns auth state and dispatch.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useAuthReducer: (initialState?: AuthState) => Omit<AuthContextProps, "service">;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useReducer } from "react";
|
|
2
|
+
import { DEFAULT_AUTH_STATE } from "../constants/auth";
|
|
3
|
+
import { authReducer } from "../reducers/auth";
|
|
4
|
+
import { initializer } from "../utils/initializer";
|
|
5
|
+
/**
|
|
6
|
+
* Auth reducer hook.
|
|
7
|
+
* @param initialState - Initial state.
|
|
8
|
+
* @returns auth state and dispatch.
|
|
9
|
+
*/
|
|
10
|
+
export const useAuthReducer = (initialState = DEFAULT_AUTH_STATE) => {
|
|
11
|
+
const [authState, authDispatch] = useReducer(authReducer, initialState, initializer);
|
|
12
|
+
return { authDispatch, authState };
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AuthenticationContextProps, AuthenticationState } from "../types/authentication";
|
|
2
|
+
/**
|
|
3
|
+
* Authentication reducer hook.
|
|
4
|
+
* @param initialState - Initial state.
|
|
5
|
+
* @returns authentication state and dispatch.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useAuthenticationReducer: (initialState?: AuthenticationState) => AuthenticationContextProps;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useReducer } from "react";
|
|
2
|
+
import { DEFAULT_AUTHENTICATION_STATE } from "../constants/authentication";
|
|
3
|
+
import { authenticationReducer } from "../reducers/authentication";
|
|
4
|
+
import { initializer } from "../utils/initializer";
|
|
5
|
+
/**
|
|
6
|
+
* Authentication reducer hook.
|
|
7
|
+
* @param initialState - Initial state.
|
|
8
|
+
* @returns authentication state and dispatch.
|
|
9
|
+
*/
|
|
10
|
+
export const useAuthenticationReducer = (initialState = DEFAULT_AUTHENTICATION_STATE) => {
|
|
11
|
+
const [authenticationState, authenticationDispatch] = useReducer(authenticationReducer, initialState, initializer);
|
|
12
|
+
return { authenticationDispatch, authenticationState };
|
|
13
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { useReducer } from "react";
|
|
2
|
-
import { DEFAULT_CREDENTIALS_STATE } from "
|
|
3
|
-
import { credentialsReducer } from "
|
|
2
|
+
import { DEFAULT_CREDENTIALS_STATE } from "../constants/credentials";
|
|
3
|
+
import { credentialsReducer } from "../reducers/credentials";
|
|
4
|
+
/**
|
|
5
|
+
* Credentials reducer hook.
|
|
6
|
+
* @returns credentials state and dispatch.
|
|
7
|
+
*/
|
|
4
8
|
export const useCredentialsReducer = () => {
|
|
5
9
|
const [credentialsState, credentialsDispatch] = useReducer(credentialsReducer, undefined, () => DEFAULT_CREDENTIALS_STATE);
|
|
6
10
|
return { credentialsDispatch, credentialsState };
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { AUTH_STATUS, AuthActionKind, } from "../types/auth";
|
|
2
|
+
/**
|
|
3
|
+
* Update auth state.
|
|
4
|
+
* @param state - State.
|
|
5
|
+
* @param payload - Payload.
|
|
6
|
+
* @returns state.
|
|
7
|
+
*/
|
|
8
|
+
function updateAuthState(state, payload) {
|
|
9
|
+
return {
|
|
10
|
+
...state,
|
|
11
|
+
...payload,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
3
14
|
/**
|
|
4
15
|
* Auth reducer.
|
|
5
16
|
* @param state - State.
|
package/lib/{providers/authentication/authentication/reducer.js → auth/reducers/authentication.js}
RENAMED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { AUTHENTICATION_STATUS, AuthenticationActionKind, } from "../types/authentication";
|
|
2
|
+
/**
|
|
3
|
+
* Update authentication action.
|
|
4
|
+
* @param state - State.
|
|
5
|
+
* @param payload - Payload.
|
|
6
|
+
* @returns state.
|
|
7
|
+
*/
|
|
8
|
+
function updateAuthenticationAction(state, payload) {
|
|
9
|
+
return {
|
|
10
|
+
...state,
|
|
11
|
+
...payload,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
3
14
|
/**
|
|
4
15
|
* Authentication reducer.
|
|
5
16
|
* Reducer for user profile and status.
|
package/lib/{providers/authentication/credentials/reducer.js → auth/reducers/credentials.js}
RENAMED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { DEFAULT_CREDENTIALS_STATE } from "../constants/credentials";
|
|
2
|
+
import { CredentialsActionKind, } from "../types/credentials";
|
|
3
|
+
/**
|
|
4
|
+
* Update credentials action.
|
|
5
|
+
* @param state - State.
|
|
6
|
+
* @param payload - Payload.
|
|
7
|
+
* @returns state.
|
|
8
|
+
*/
|
|
9
|
+
function updateCredentialsAction(state, payload) {
|
|
10
|
+
return {
|
|
11
|
+
...state,
|
|
12
|
+
credentials: payload,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
16
|
* Credentials reducer.
|
|
6
17
|
* @param state - State.
|
|
@@ -1,31 +1,58 @@
|
|
|
1
1
|
import { Dispatch } from "react";
|
|
2
|
-
import { ProviderId } from "
|
|
3
|
-
|
|
2
|
+
import { ProviderId } from "./common";
|
|
3
|
+
/**
|
|
4
|
+
* Auth action type - union of all possible auth actions.
|
|
5
|
+
*/
|
|
6
|
+
export type AuthAction = RequestAuthAction | AuthResetStateAction | UpdateAuthStateAction;
|
|
7
|
+
/**
|
|
8
|
+
* Auth action kinds.
|
|
9
|
+
*/
|
|
4
10
|
export declare enum AuthActionKind {
|
|
5
11
|
RequestAuth = "REQUEST_AUTH",
|
|
6
12
|
ResetState = "RESET_STATE",
|
|
7
13
|
UpdateAuthState = "UPDATE_AUTH_STATE"
|
|
8
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Auth context properties.
|
|
17
|
+
*/
|
|
9
18
|
export interface AuthContextProps {
|
|
10
19
|
authDispatch: Dispatch<AuthAction> | null;
|
|
11
20
|
authState: AuthState;
|
|
12
21
|
service: Service | undefined;
|
|
13
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Auth state.
|
|
25
|
+
*/
|
|
14
26
|
export interface AuthState {
|
|
15
27
|
initialState?: AuthState;
|
|
16
28
|
isAuthenticated: boolean;
|
|
17
29
|
status: AUTH_STATUS;
|
|
18
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Request auth action.
|
|
33
|
+
*/
|
|
19
34
|
export type RequestAuthAction = {
|
|
20
35
|
payload: RequestAuthPayload;
|
|
21
36
|
type: AuthActionKind.RequestAuth;
|
|
22
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Request auth payload.
|
|
40
|
+
*/
|
|
23
41
|
export type RequestAuthPayload = undefined;
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Auth reset state action.
|
|
44
|
+
*/
|
|
45
|
+
export type AuthResetStateAction = {
|
|
46
|
+
payload: AuthResetStatePayload;
|
|
26
47
|
type: AuthActionKind.ResetState;
|
|
27
48
|
};
|
|
28
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Auth reset state payload.
|
|
51
|
+
*/
|
|
52
|
+
export type AuthResetStatePayload = undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Auth service interface.
|
|
55
|
+
*/
|
|
29
56
|
export interface Service {
|
|
30
57
|
[key: string]: unknown;
|
|
31
58
|
requestLogin: (providerId: ProviderId) => void;
|
|
@@ -34,14 +61,23 @@ export interface Service {
|
|
|
34
61
|
redirect?: boolean;
|
|
35
62
|
}) => void;
|
|
36
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Auth status enum.
|
|
66
|
+
*/
|
|
37
67
|
export declare enum AUTH_STATUS {
|
|
38
68
|
PENDING = "PENDING",
|
|
39
69
|
SETTLED = "SETTLED"
|
|
40
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Update auth state action.
|
|
73
|
+
*/
|
|
41
74
|
export interface UpdateAuthStateAction {
|
|
42
75
|
payload: UpdateAuthStatePayload;
|
|
43
76
|
type: AuthActionKind.UpdateAuthState;
|
|
44
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Update auth state payload.
|
|
80
|
+
*/
|
|
45
81
|
export interface UpdateAuthStatePayload {
|
|
46
82
|
isAuthenticated?: boolean;
|
|
47
83
|
status?: AUTH_STATUS;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth action kinds.
|
|
3
|
+
*/
|
|
1
4
|
export var AuthActionKind;
|
|
2
5
|
(function (AuthActionKind) {
|
|
3
6
|
AuthActionKind["RequestAuth"] = "REQUEST_AUTH";
|
|
4
7
|
AuthActionKind["ResetState"] = "RESET_STATE";
|
|
5
8
|
AuthActionKind["UpdateAuthState"] = "UPDATE_AUTH_STATE";
|
|
6
9
|
})(AuthActionKind || (AuthActionKind = {}));
|
|
10
|
+
/**
|
|
11
|
+
* Auth status enum.
|
|
12
|
+
*/
|
|
7
13
|
export var AUTH_STATUS;
|
|
8
14
|
(function (AUTH_STATUS) {
|
|
9
15
|
AUTH_STATUS["PENDING"] = "PENDING";
|