@forward-software/react-auth 1.1.0 → 2.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/LICENSE +2 -2
- package/README.md +91 -44
- package/dist/auth.d.ts +237 -0
- package/dist/auth.js +215 -0
- package/dist/index.d.ts +2 -21
- package/dist/index.js +1 -8
- package/dist/{types/eventEmitter.d.ts → utils.d.ts} +17 -10
- package/dist/utils.js +30 -0
- package/package.json +28 -60
- package/src/auth.tsx +546 -0
- package/src/index.ts +2 -0
- package/src/{types/eventEmitter.ts → utils.ts} +25 -2
- package/dist/react-auth.cjs.development.js +0 -789
- package/dist/react-auth.cjs.development.js.map +0 -1
- package/dist/react-auth.cjs.production.min.js +0 -2
- package/dist/react-auth.cjs.production.min.js.map +0 -1
- package/dist/react-auth.esm.js +0 -781
- package/dist/react-auth.esm.js.map +0 -1
- package/dist/types/deferred.d.ts +0 -7
- package/dist/types/index.d.ts +0 -56
- package/src/index.tsx +0 -98
- package/src/types/deferred.ts +0 -18
- package/src/types/index.ts +0 -298
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Props that can be passed to AuthProvider
|
|
5
|
-
*/
|
|
6
|
-
export declare type AuthProviderProps = {
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
* An optional component to display if AuthClient initialization failed.
|
|
10
|
-
*/
|
|
11
|
-
ErrorComponent?: JSX.Element;
|
|
12
|
-
/**
|
|
13
|
-
* An optional component to display while AuthClient instance is being initialized.
|
|
14
|
-
*/
|
|
15
|
-
LoadingComponent?: JSX.Element;
|
|
16
|
-
};
|
|
17
|
-
export declare function createAuth<C extends BaseAuthClient>(authClient: C): {
|
|
18
|
-
AuthProvider: React.FC<AuthProviderProps>;
|
|
19
|
-
useAuthClient: () => C;
|
|
20
|
-
};
|
|
21
|
-
export { BaseAuthClient };
|
|
1
|
+
export { createAuth } from "./auth";
|
|
2
|
+
export type { AuthClient } from "./auth";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
export
|
|
1
|
+
export declare class Deferred<T> {
|
|
2
|
+
private promise;
|
|
3
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
4
|
+
reject: (reason?: any) => void;
|
|
5
|
+
constructor();
|
|
6
|
+
getPromise(): Promise<T>;
|
|
7
|
+
}
|
|
8
|
+
type EventsMap = Record<string, any>;
|
|
9
|
+
export type EventKey<T extends EventsMap> = string & keyof T;
|
|
10
|
+
export type EventReceiver<T> = (params: T) => void;
|
|
11
|
+
interface Emitter<T extends EventsMap> {
|
|
12
|
+
on<K extends EventKey<T>>(eventName: K, fn: EventReceiver<T[K]>): void;
|
|
13
|
+
off<K extends EventKey<T>>(eventName: K, fn: EventReceiver<T[K]>): void;
|
|
14
|
+
emit<K extends EventKey<T>>(eventName: K, params: T[K]): void;
|
|
15
|
+
}
|
|
16
|
+
export declare function createEventEmitter<T extends EventsMap>(): Emitter<T>;
|
|
17
|
+
export {};
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class Deferred {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.promise = new Promise((resolve, reject) => {
|
|
4
|
+
this.reject = reject;
|
|
5
|
+
this.resolve = resolve;
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
getPromise() {
|
|
9
|
+
return this.promise;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function createEventEmitter() {
|
|
13
|
+
const listeners = {};
|
|
14
|
+
return {
|
|
15
|
+
on(key, fn) {
|
|
16
|
+
listeners[key] = (listeners[key] || []).concat(fn);
|
|
17
|
+
},
|
|
18
|
+
off(key, fn) {
|
|
19
|
+
listeners[key] = (listeners[key] || []).filter((f) => f !== fn);
|
|
20
|
+
},
|
|
21
|
+
emit(key, data) {
|
|
22
|
+
(listeners[key] || []).forEach(function (fn) {
|
|
23
|
+
try {
|
|
24
|
+
fn(data);
|
|
25
|
+
}
|
|
26
|
+
catch (_a) { }
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forward-software/react-auth",
|
|
3
|
-
"version": "1.1.0",
|
|
4
|
-
"author": "ForWarD Software (https://github.com/Forward-Software)",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
3
|
"description": "Simplify your Auth flow when working with React apps",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
4
|
+
"version": "2.0.0",
|
|
5
|
+
"author": "ForWarD Software (https://forwardsoftware.solutions/)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": "https://github.com/forwardsoftware/react-auth",
|
|
8
|
+
"homepage": "https://github.com/forwardsoftware/react-auth#readme",
|
|
12
9
|
"keywords": [
|
|
13
10
|
"react",
|
|
14
11
|
"react-native",
|
|
@@ -16,70 +13,41 @@
|
|
|
16
13
|
"authentication"
|
|
17
14
|
],
|
|
18
15
|
"main": "dist/index.js",
|
|
19
|
-
"
|
|
20
|
-
"module": "dist/react-auth.esm.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
21
17
|
"react-native": "src/index.tsx",
|
|
22
18
|
"source": "src/index.tsx",
|
|
23
19
|
"files": [
|
|
24
20
|
"dist",
|
|
25
21
|
"src"
|
|
26
22
|
],
|
|
27
|
-
"engines": {
|
|
28
|
-
"node": ">=12"
|
|
29
|
-
},
|
|
30
23
|
"scripts": {
|
|
31
|
-
"
|
|
32
|
-
"build": "
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"test
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"size": "size-limit",
|
|
39
|
-
"analyze": "size-limit --why",
|
|
40
|
-
"examples:base": "yarn --cwd examples/base",
|
|
41
|
-
"examples:reqres": "yarn --cwd examples/reqres",
|
|
42
|
-
"examples:refresh-token": "yarn --cwd examples/refresh-token",
|
|
43
|
-
"examples:native": "yarn --cwd examples/native"
|
|
24
|
+
"build:code": "tsc --removeComments",
|
|
25
|
+
"build:types": "tsc --declaration --emitDeclarationOnly",
|
|
26
|
+
"build": "run-p clean build:*",
|
|
27
|
+
"lint": "eslint src",
|
|
28
|
+
"test": "vitest",
|
|
29
|
+
"test:watch": "vitest watch",
|
|
30
|
+
"clean": "rimraf dist"
|
|
44
31
|
},
|
|
45
32
|
"devDependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@testing-library/jest-dom": "^
|
|
48
|
-
"@testing-library/react": "^
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/react
|
|
51
|
-
"@types/
|
|
52
|
-
"
|
|
53
|
-
"react": "
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
33
|
+
"@testing-library/dom": "^10.0.0",
|
|
34
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
35
|
+
"@testing-library/react": "^16.3.0",
|
|
36
|
+
"@types/node": "^22.15.17",
|
|
37
|
+
"@types/react": "catalog:",
|
|
38
|
+
"@types/react-dom": "catalog:",
|
|
39
|
+
"@types/use-sync-external-store": "^1.5.0",
|
|
40
|
+
"@vitejs/plugin-react": "catalog:",
|
|
41
|
+
"jsdom": "^26.1.0",
|
|
42
|
+
"react": "catalog:",
|
|
43
|
+
"react-dom": "catalog:",
|
|
44
|
+
"vite": "catalog:",
|
|
45
|
+
"vitest": "^3.1.2"
|
|
57
46
|
},
|
|
58
47
|
"dependencies": {
|
|
59
|
-
"use-sync-external-store": "^1.
|
|
48
|
+
"use-sync-external-store": "^1.5.0"
|
|
60
49
|
},
|
|
61
50
|
"peerDependencies": {
|
|
62
51
|
"react": ">=16.8"
|
|
63
|
-
}
|
|
64
|
-
"husky": {
|
|
65
|
-
"hooks": {
|
|
66
|
-
"pre-commit": "tsdx lint"
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
"prettier": {
|
|
70
|
-
"printWidth": 80,
|
|
71
|
-
"semi": true,
|
|
72
|
-
"singleQuote": true,
|
|
73
|
-
"trailingComma": "es5"
|
|
74
|
-
},
|
|
75
|
-
"size-limit": [
|
|
76
|
-
{
|
|
77
|
-
"path": "dist/react-auth.cjs.production.min.js",
|
|
78
|
-
"limit": "10 KB"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"path": "dist/react-auth.esm.js",
|
|
82
|
-
"limit": "10 KB"
|
|
83
|
-
}
|
|
84
|
-
]
|
|
52
|
+
}
|
|
85
53
|
}
|