mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Added react-auth-kit (#47368)
* Added react-auth-kit * fix: Not used file error Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com> * fix: TokenObject.d.ts not found * del: Unused Test file Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com> * fix: Error of import Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com> * fix: Errors on AuthProvier and HOCs Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com> * fix: prefer-declare-function errors Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com> * removed: utility types Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com> * fix: Higher order components errors Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com> * fix: New line Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com> * deleted: not needed files and test file Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com> * fix: tsconfig error Signed-off-by: Arkadip Bhattacharya <in2arkadipb13@gmail.com>
This commit is contained in:
parent
7e6e8a9284
commit
8f5c2db8f8
31
types/react-auth-kit/AuthProvider.d.ts
vendored
Normal file
31
types/react-auth-kit/AuthProvider.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import * as React from 'react';
|
||||
import { TokenInterface, TokenObjectParamsInterface } from "./types";
|
||||
interface AuthProviderProps extends TokenObjectParamsInterface {
|
||||
children: React.ReactChildren;
|
||||
}
|
||||
/**
|
||||
* AuthContextInterface
|
||||
*
|
||||
* authState - Stores the value of authentication State
|
||||
* setAuthState - Sets the authState Value
|
||||
*/
|
||||
interface AuthContextInterface {
|
||||
authState: TokenInterface;
|
||||
setAuthState: React.Dispatch<React.SetStateAction<TokenInterface>>;
|
||||
}
|
||||
declare const AuthContext: React.Context<AuthContextInterface | null>;
|
||||
/**
|
||||
* AuthProvider - The Authentication Context Provider
|
||||
*
|
||||
* @param children
|
||||
* @param authStorageName
|
||||
* @param authStorageType
|
||||
* @param authTimeStorageName
|
||||
* @param cookieDomain
|
||||
* @param cookieSecure
|
||||
* @param stateStorageName
|
||||
*/
|
||||
declare const AuthProvider: React.FunctionComponent<AuthProviderProps>;
|
||||
export default AuthProvider;
|
||||
declare const AuthContextConsumer: React.Consumer<AuthContextInterface | null>;
|
||||
export { AuthContext, AuthContextConsumer };
|
||||
16
types/react-auth-kit/PrivateRoute.d.ts
vendored
Normal file
16
types/react-auth-kit/PrivateRoute.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import { RouteProps } from 'react-router-dom';
|
||||
interface PrivateRouteProps extends RouteProps {
|
||||
loginPath: string;
|
||||
}
|
||||
/**
|
||||
* Private Route for Components
|
||||
*
|
||||
* @remarks
|
||||
* This Component is based on {@link https://reactrouter.com/web/api/Route | reactrouter.Route}.
|
||||
* So you need to install react-route-dom before use it
|
||||
*
|
||||
* @param props
|
||||
*/
|
||||
declare const PrivateRoute: React.FunctionComponent<PrivateRouteProps>;
|
||||
export default PrivateRoute;
|
||||
6
types/react-auth-kit/higherOrderComponents/withAuth.d.ts
vendored
Normal file
6
types/react-auth-kit/higherOrderComponents/withAuth.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import * as React from 'react';
|
||||
interface withAuthProps {
|
||||
authState: object | null;
|
||||
}
|
||||
declare function withAuth<P extends withAuthProps>(Component: React.ComponentType<P>): React.FC<P>;
|
||||
export default withAuth;
|
||||
6
types/react-auth-kit/higherOrderComponents/withAuthHeader.d.ts
vendored
Normal file
6
types/react-auth-kit/higherOrderComponents/withAuthHeader.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import * as React from 'react';
|
||||
interface withAuthHeaderProps {
|
||||
authHeader: string;
|
||||
}
|
||||
declare function withAuthHeader<P extends withAuthHeaderProps>(Component: React.ComponentType<P>): React.FC<P>;
|
||||
export default withAuthHeader;
|
||||
7
types/react-auth-kit/higherOrderComponents/withSignIn.d.ts
vendored
Normal file
7
types/react-auth-kit/higherOrderComponents/withSignIn.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import { signInFunctionParams } from "../types";
|
||||
interface withSignInProps {
|
||||
signIn(params: signInFunctionParams): boolean;
|
||||
}
|
||||
declare function withSignIn<P extends withSignInProps>(Component: React.ComponentType<P>): React.FC<P>;
|
||||
export default withSignIn;
|
||||
6
types/react-auth-kit/higherOrderComponents/withSignOut.d.ts
vendored
Normal file
6
types/react-auth-kit/higherOrderComponents/withSignOut.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import * as React from 'react';
|
||||
interface withSignOutProps {
|
||||
signOut(): boolean;
|
||||
}
|
||||
declare function withSignOut<P extends withSignOutProps>(Component: React.ComponentType<P>): React.FC<P>;
|
||||
export default withSignOut;
|
||||
8
types/react-auth-kit/hooks/useAuth.d.ts
vendored
Normal file
8
types/react-auth-kit/hooks/useAuth.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { TokenInterface } from "../types";
|
||||
/**
|
||||
* Auth State Hook
|
||||
*
|
||||
* @returns - Auth State Function
|
||||
*/
|
||||
declare function useAuth(): () => TokenInterface;
|
||||
export default useAuth;
|
||||
2
types/react-auth-kit/hooks/useAuthHeader.d.ts
vendored
Normal file
2
types/react-auth-kit/hooks/useAuthHeader.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
declare function useAuthHeader(): () => (string);
|
||||
export default useAuthHeader;
|
||||
8
types/react-auth-kit/hooks/useSignIn.d.ts
vendored
Normal file
8
types/react-auth-kit/hooks/useSignIn.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { signInFunctionParams } from "../types";
|
||||
/**
|
||||
* Authentication SignIn Hook
|
||||
*
|
||||
* @returns - Sign In function
|
||||
*/
|
||||
declare function useSignIn(): ({ token, authState, expiresIn, tokenType }: signInFunctionParams) => boolean;
|
||||
export default useSignIn;
|
||||
2
types/react-auth-kit/hooks/useSignOut.d.ts
vendored
Normal file
2
types/react-auth-kit/hooks/useSignOut.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
declare function useSignOut(): () => (boolean);
|
||||
export default useSignOut;
|
||||
16
types/react-auth-kit/index.d.ts
vendored
Normal file
16
types/react-auth-kit/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Type definitions for react-auth-kit 1.1
|
||||
// Project: https://github.com/react-auth-kit/react-auth-kit#readme
|
||||
// Definitions by: Arkadip Bhattacharya <https://github.com/darkmatter18>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import AuthProvider from './AuthProvider';
|
||||
import PrivateRoute from './PrivateRoute';
|
||||
import useSignIn from './hooks/useSignIn';
|
||||
import useSignOut from './hooks/useSignOut';
|
||||
import useAuth from './hooks/useAuth';
|
||||
import useAuthHeader from './hooks/useAuthHeader';
|
||||
import withAuth from './higherOrderComponents/withAuth';
|
||||
import withAuthHeader from './higherOrderComponents/withAuthHeader';
|
||||
import withSignIn from './higherOrderComponents/withSignIn';
|
||||
import withSignOut from './higherOrderComponents/withSignOut';
|
||||
export { AuthProvider, PrivateRoute, useSignIn, useSignOut, useAuth, useAuthHeader, withAuth, withAuthHeader, withSignIn, withSignOut };
|
||||
22
types/react-auth-kit/tsconfig.json
Normal file
22
types/react-auth-kit/tsconfig.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
]
|
||||
}
|
||||
1
types/react-auth-kit/tslint.json
Normal file
1
types/react-auth-kit/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
20
types/react-auth-kit/types.d.ts
vendored
Normal file
20
types/react-auth-kit/types.d.ts
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
export interface TokenInterface {
|
||||
authToken: string | null;
|
||||
authTokenType: string | null;
|
||||
expireAt: Date | null;
|
||||
authState: object | null;
|
||||
}
|
||||
export interface signInFunctionParams {
|
||||
token: string;
|
||||
tokenType: string | 'Bearer';
|
||||
expiresIn: number;
|
||||
authState: object;
|
||||
}
|
||||
export interface TokenObjectParamsInterface {
|
||||
authStorageType: 'cookie' | 'localstorage';
|
||||
authStorageName: string;
|
||||
authTimeStorageName: string;
|
||||
stateStorageName: string;
|
||||
cookieDomain?: string;
|
||||
cookieSecure?: boolean;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user