@tasoskakour/react-use-oauth2 1.0.7
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/README.md +178 -0
- package/dist/cjs/index.js +70 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types/OAuthPopup.d.ts +6 -0
- package/dist/cjs/types/constants.d.ts +5 -0
- package/dist/cjs/types/index.d.ts +2 -0
- package/dist/cjs/types/tools.d.ts +4 -0
- package/dist/cjs/types/use-oauth2.d.ts +31 -0
- package/dist/esm/index.js +70 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/OAuthPopup.d.ts +6 -0
- package/dist/esm/types/constants.d.ts +5 -0
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/types/tools.d.ts +4 -0
- package/dist/esm/types/use-oauth2.d.ts +31 -0
- package/dist/index.d.ts +38 -0
- package/package.json +106 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const POPUP_HEIGHT = 700;
|
|
2
|
+
export declare const POPUP_WIDTH = 600;
|
|
3
|
+
export declare const OAUTH_STATE_KEY = "react-use-oauth2-state-key";
|
|
4
|
+
export declare const OAUTH_RESPONSE = "react-use-oauth2-response";
|
|
5
|
+
export declare const DEFAULT_EXCHANGE_CODE_FOR_TOKEN_METHOD = "POST";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare type AuthTokenPayload = {
|
|
2
|
+
token_type: string;
|
|
3
|
+
expires_in: number;
|
|
4
|
+
access_token: string;
|
|
5
|
+
scope: string;
|
|
6
|
+
refresh_token: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type ResponseTypeBasedProps<TData> = {
|
|
9
|
+
responseType: 'code';
|
|
10
|
+
exchangeCodeForTokenServerURL: string;
|
|
11
|
+
exchangeCodeForTokenMethod?: 'POST' | 'GET';
|
|
12
|
+
onSuccess?: (payload: TData) => void;
|
|
13
|
+
} | {
|
|
14
|
+
responseType: 'token';
|
|
15
|
+
onSuccess?: (payload: TData) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare type Oauth2Props<TData = AuthTokenPayload> = {
|
|
18
|
+
authorizeUrl: string;
|
|
19
|
+
clientId: string;
|
|
20
|
+
redirectUri: string;
|
|
21
|
+
scope?: string;
|
|
22
|
+
onError?: (error: string) => void;
|
|
23
|
+
} & ResponseTypeBasedProps<TData>;
|
|
24
|
+
export declare type State<TData = AuthTokenPayload> = TData | null;
|
|
25
|
+
declare const useOAuth2: <TData = AuthTokenPayload>(props: Oauth2Props<TData>) => {
|
|
26
|
+
data: State<AuthTokenPayload>;
|
|
27
|
+
loading: boolean;
|
|
28
|
+
error: null;
|
|
29
|
+
getAuth: () => () => void;
|
|
30
|
+
};
|
|
31
|
+
export default useOAuth2;
|