@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.
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ Component?: React.ReactElement;
4
+ };
5
+ declare const OAuthPopup: (props: Props) => JSX.Element;
6
+ export default OAuthPopup;
@@ -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,2 @@
1
+ export { default as OAuthPopup } from './OAuthPopup';
2
+ export { default as useOAuth2 } from './use-oauth2';
@@ -0,0 +1,4 @@
1
+ export declare const objectToQuery: (object: Record<string, string>) => string;
2
+ export declare const queryToObject: (query: string) => {
3
+ [k: string]: string;
4
+ };
@@ -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;