@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;
@@ -0,0 +1,38 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ Component?: React.ReactElement;
4
+ };
5
+ declare const OAuthPopup: (props: Props) => JSX.Element;
6
+
7
+ declare type AuthTokenPayload = {
8
+ token_type: string;
9
+ expires_in: number;
10
+ access_token: string;
11
+ scope: string;
12
+ refresh_token: string;
13
+ };
14
+ declare type ResponseTypeBasedProps<TData> = {
15
+ responseType: 'code';
16
+ exchangeCodeForTokenServerURL: string;
17
+ exchangeCodeForTokenMethod?: 'POST' | 'GET';
18
+ onSuccess?: (payload: TData) => void;
19
+ } | {
20
+ responseType: 'token';
21
+ onSuccess?: (payload: TData) => void;
22
+ };
23
+ declare type Oauth2Props<TData = AuthTokenPayload> = {
24
+ authorizeUrl: string;
25
+ clientId: string;
26
+ redirectUri: string;
27
+ scope?: string;
28
+ onError?: (error: string) => void;
29
+ } & ResponseTypeBasedProps<TData>;
30
+ declare type State<TData = AuthTokenPayload> = TData | null;
31
+ declare const useOAuth2: <TData = AuthTokenPayload>(props: Oauth2Props<TData>) => {
32
+ data: State<AuthTokenPayload>;
33
+ loading: boolean;
34
+ error: null;
35
+ getAuth: () => () => void;
36
+ };
37
+
38
+ export { OAuthPopup, useOAuth2 };
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "@tasoskakour/react-use-oauth2",
3
+ "author": {
4
+ "name": "Tasos Kakouris",
5
+ "email": "tasoskakour@gmail.com",
6
+ "website": "https://tasoskakour.com"
7
+ },
8
+ "keywords": [
9
+ "react",
10
+ "hooks",
11
+ "typescript",
12
+ "nodejs",
13
+ "oauth2"
14
+ ],
15
+ "version": "1.0.7",
16
+ "description": "A React hook that handles OAuth2 authorization flow.",
17
+ "license": "MIT",
18
+ "homepage": "https://github.com/tasoskakour/react-use-oauth2#readme",
19
+ "bugs": {
20
+ "url": "https://github.com/tasoskakour/react-use-oauth2/issues"
21
+ },
22
+ "repository": "github:tasoskakour/react-use-oauth2",
23
+ "main": "dist/cjs/index.js",
24
+ "module": "dist/esm/index.js",
25
+ "dependencies": {
26
+ "use-local-storage-state": "^17.0.1"
27
+ },
28
+ "scripts": {
29
+ "build": "rollup -c",
30
+ "example": "rollup -c rollup.config.example.js -w",
31
+ "test": "NODE_ENV=test npm run lint && start-server-and-test example \"3000|3001\" jest",
32
+ "lint": "eslint . --cache",
33
+ "prepare": "husky install"
34
+ },
35
+ "browserslist": {
36
+ "production": [
37
+ ">1%",
38
+ "not dead",
39
+ "not op_mini all",
40
+ "not ie > 0",
41
+ "not ie_mob > 0"
42
+ ],
43
+ "development": [
44
+ "last 1 chrome version",
45
+ "last 1 firefox version",
46
+ "last 1 safari version"
47
+ ]
48
+ },
49
+ "peerDependencies": {
50
+ "react": "^17.0.2"
51
+ },
52
+ "devDependencies": {
53
+ "@babel/core": "^7.17.5",
54
+ "@babel/plugin-transform-runtime": "^7.17.0",
55
+ "@babel/preset-env": "^7.16.11",
56
+ "@babel/preset-react": "^7.16.7",
57
+ "@babel/preset-typescript": "^7.16.7",
58
+ "@rollup/plugin-commonjs": "^21.0.2",
59
+ "@rollup/plugin-json": "^4.1.0",
60
+ "@rollup/plugin-node-resolve": "^13.1.3",
61
+ "@rollup/plugin-replace": "^4.0.0",
62
+ "@rollup/plugin-run": "^2.1.0",
63
+ "@rollup/plugin-typescript": "^8.3.1",
64
+ "@types/jest": "^27.4.1",
65
+ "@types/node": "^17.0.21",
66
+ "@types/react": "^17.0.39",
67
+ "@types/react-dom": "^17.0.13",
68
+ "babel-jest": "^27.5.1",
69
+ "babel-loader": "^8.2.3",
70
+ "builtin-modules": "^3.2.0",
71
+ "delay": "^5.0.0",
72
+ "eslint": "^8.10.0",
73
+ "eslint-config-tasoskakour-typescript-prettier": "^2.0.5",
74
+ "fastify": "^3.27.4",
75
+ "husky": "^7.0.4",
76
+ "jest": "^27.5.1",
77
+ "jest-puppeteer": "^6.1.0",
78
+ "lint-staged": "^12.3.5",
79
+ "puppeteer": "^13.5.2",
80
+ "react-dom": "^17.0.2",
81
+ "react-router-dom": "^6.2.2",
82
+ "rollup": "^2.69.2",
83
+ "rollup-plugin-delete": "^2.0.0",
84
+ "rollup-plugin-dts": "^4.2.0",
85
+ "rollup-plugin-livereload": "^2.0.5",
86
+ "rollup-plugin-peer-deps-external": "^2.2.4",
87
+ "rollup-plugin-serve": "^1.1.0",
88
+ "rollup-plugin-terser": "^7.0.2",
89
+ "start-server-and-test": "^1.14.0",
90
+ "ts-jest": "^27.1.3",
91
+ "typescript": "^4.6.2"
92
+ },
93
+ "engines": {
94
+ "node": ">=14"
95
+ },
96
+ "files": [
97
+ "dist"
98
+ ],
99
+ "types": "dist/index.d.ts",
100
+ "lint-staged": {
101
+ "*.{js,ts,tsx}": "eslint --cache --fix"
102
+ },
103
+ "publishConfig": {
104
+ "access": "public"
105
+ }
106
+ }