react-firebase-ql 4.0.6 → 4.1.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/dist/client/AuthProvider.provider.d.ts +2 -2
- package/dist/client/AuthProvider.provider.js +8 -18
- package/dist/client/AuthProvider.provider.js.map +1 -1
- package/esm/client/AuthProvider.provider.js +8 -18
- package/esm/client/AuthProvider.provider.js.map +1 -1
- package/package.json +1 -1
- package/src/client/AuthProvider.provider.tsx +13 -25
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode, Context } from 'react';
|
|
2
|
-
import { Auth
|
|
2
|
+
import { Auth } from 'firebase/auth';
|
|
3
3
|
interface AUTHSTATE {
|
|
4
|
-
|
|
4
|
+
UID?: string;
|
|
5
5
|
}
|
|
6
6
|
export declare const AUTHContext: Context<AUTHSTATE>;
|
|
7
7
|
type AUTHProviderProps = {
|
|
@@ -5,23 +5,21 @@ exports.AUTHProvider = exports.AUTHContext = void 0;
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const auth_1 = require("firebase/auth");
|
|
8
|
-
const firebase_client_ql_1 = require("firebase-client-ql");
|
|
9
8
|
var AUTHACTIONTYPE;
|
|
10
9
|
(function (AUTHACTIONTYPE) {
|
|
11
|
-
AUTHACTIONTYPE["
|
|
10
|
+
AUTHACTIONTYPE["SETUID"] = "SETFBUSER";
|
|
12
11
|
})(AUTHACTIONTYPE || (AUTHACTIONTYPE = {}));
|
|
13
12
|
const initialAUTHState = {};
|
|
14
13
|
const AUTHReducer = (state, action) => {
|
|
15
|
-
var _a;
|
|
16
14
|
switch (action.type) {
|
|
17
|
-
case AUTHACTIONTYPE.
|
|
15
|
+
case AUTHACTIONTYPE.SETUID: {
|
|
18
16
|
const nextUser = action.payload;
|
|
19
|
-
if (
|
|
17
|
+
if (state.UID === nextUser) {
|
|
20
18
|
return state;
|
|
21
19
|
}
|
|
22
20
|
return {
|
|
23
21
|
...state,
|
|
24
|
-
|
|
22
|
+
UID: nextUser,
|
|
25
23
|
};
|
|
26
24
|
}
|
|
27
25
|
default:
|
|
@@ -36,18 +34,10 @@ const AUTHProvider = ({ children, auth }) => {
|
|
|
36
34
|
(0, react_1.useEffect)(() => {
|
|
37
35
|
const unsubscribe = (0, auth_1.onAuthStateChanged)(auth, (authUser) => {
|
|
38
36
|
var _a;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
dispatch({
|
|
44
|
-
type: AUTHACTIONTYPE.SETFBUSER,
|
|
45
|
-
payload: authUser !== null && authUser !== void 0 ? authUser : undefined,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
(0, firebase_client_ql_1.errorLogger)('User Authentication error:', error);
|
|
50
|
-
}
|
|
37
|
+
dispatch({
|
|
38
|
+
type: AUTHACTIONTYPE.SETUID,
|
|
39
|
+
payload: (_a = authUser === null || authUser === void 0 ? void 0 : authUser.uid) !== null && _a !== void 0 ? _a : undefined,
|
|
40
|
+
});
|
|
51
41
|
});
|
|
52
42
|
return unsubscribe;
|
|
53
43
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider.provider.js","sourceRoot":"","sources":["../../src/client/AuthProvider.provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;AAEb,iCAOe;AAEf,wCAA+D;
|
|
1
|
+
{"version":3,"file":"AuthProvider.provider.js","sourceRoot":"","sources":["../../src/client/AuthProvider.provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;AAEb,iCAOe;AAEf,wCAA+D;AAE/D,IAAK,cAEJ;AAFD,WAAK,cAAc;IACf,sCAAoB,CAAA;AACxB,CAAC,EAFI,cAAc,KAAd,cAAc,QAElB;AAgBD,MAAM,gBAAgB,GAAc,EAAE,CAAA;AAEtC,MAAM,WAAW,GAAG,CAAC,KAAgB,E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QAAQ,YACnC,QAAQ,GACa,GACH,CACxB,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,YAAY,gBAyBvB"}
|
|
@@ -2,23 +2,21 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useReducer, createContext, useEffect, } from 'react';
|
|
4
4
|
import { onAuthStateChanged } from 'firebase/auth';
|
|
5
|
-
import { errorLogger } from 'firebase-client-ql';
|
|
6
5
|
var AUTHACTIONTYPE;
|
|
7
6
|
(function (AUTHACTIONTYPE) {
|
|
8
|
-
AUTHACTIONTYPE["
|
|
7
|
+
AUTHACTIONTYPE["SETUID"] = "SETFBUSER";
|
|
9
8
|
})(AUTHACTIONTYPE || (AUTHACTIONTYPE = {}));
|
|
10
9
|
const initialAUTHState = {};
|
|
11
10
|
const AUTHReducer = (state, action) => {
|
|
12
|
-
var _a;
|
|
13
11
|
switch (action.type) {
|
|
14
|
-
case AUTHACTIONTYPE.
|
|
12
|
+
case AUTHACTIONTYPE.SETUID: {
|
|
15
13
|
const nextUser = action.payload;
|
|
16
|
-
if (
|
|
14
|
+
if (state.UID === nextUser) {
|
|
17
15
|
return state;
|
|
18
16
|
}
|
|
19
17
|
return {
|
|
20
18
|
...state,
|
|
21
|
-
|
|
19
|
+
UID: nextUser,
|
|
22
20
|
};
|
|
23
21
|
}
|
|
24
22
|
default:
|
|
@@ -33,18 +31,10 @@ export const AUTHProvider = ({ children, auth }) => {
|
|
|
33
31
|
useEffect(() => {
|
|
34
32
|
const unsubscribe = onAuthStateChanged(auth, (authUser) => {
|
|
35
33
|
var _a;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
dispatch({
|
|
41
|
-
type: AUTHACTIONTYPE.SETFBUSER,
|
|
42
|
-
payload: authUser !== null && authUser !== void 0 ? authUser : undefined,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
errorLogger('User Authentication error:', error);
|
|
47
|
-
}
|
|
34
|
+
dispatch({
|
|
35
|
+
type: AUTHACTIONTYPE.SETUID,
|
|
36
|
+
payload: (_a = authUser === null || authUser === void 0 ? void 0 : authUser.uid) !== null && _a !== void 0 ? _a : undefined,
|
|
37
|
+
});
|
|
48
38
|
});
|
|
49
39
|
return unsubscribe;
|
|
50
40
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider.provider.js","sourceRoot":"","sources":["../../src/client/AuthProvider.provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAGL,UAAU,EAEV,aAAa,EACb,SAAS,GACV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAc,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthProvider.provider.js","sourceRoot":"","sources":["../../src/client/AuthProvider.provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAGL,UAAU,EAEV,aAAa,EACb,SAAS,GACV,MAAM,OAAO,CAAC;AAEf,OAAO,EAAc,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE/D,IAAK,cAEJ;AAFD,WAAK,cAAc;IACf,sCAAoB,CAAA;AACxB,CAAC,EAFI,cAAc,KAAd,cAAc,QAElB;AAgBD,MAAM,gBAAgB,GAAc,EAAE,CAAA;AAEtC,MAAM,WAAW,GAAG,CAAC,KAAgB,EAAE,MAAkB,EAAa,EAAE;IACtE,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;YAC3B,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;YAEhC,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC3B,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO;gBACL,GAAG,KAAK;gBACR,GAAG,EAAE,QAAQ;aACd,CAAC;QACJ,CAAC;QAED;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAIF,MAAM,eAAe,GAAyB,GAAG,EAAE,GAAE,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,WAAW,GACtB,aAAa,CAAC,gBAAgB,CAAC,CAAC;AAElC,MAAM,YAAY,GAChB,aAAa,CAAC,eAAe,CAAC,CAAC;AAOjC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAqB,EAAE,EAAE;IACpE,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,UAAU,CACtC,WAAW,EACX,gBAAgB,CACjB,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE;;YAExD,QAAQ,CAAC;gBACL,IAAI,EAAE,cAAc,CAAC,MAAM;gBAC3B,OAAO,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,mCAAI,SAAS;aACpC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEL,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS,YACpC,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YACnC,QAAQ,GACa,GACH,CACxB,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -10,10 +10,9 @@ import {
|
|
|
10
10
|
} from 'react';
|
|
11
11
|
|
|
12
12
|
import { Auth, User, onAuthStateChanged } from 'firebase/auth';
|
|
13
|
-
import { errorLogger } from 'firebase-client-ql';
|
|
14
13
|
|
|
15
14
|
enum AUTHACTIONTYPE {
|
|
16
|
-
|
|
15
|
+
SETUID = "SETFBUSER",
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
/**
|
|
@@ -21,12 +20,12 @@ enum AUTHACTIONTYPE {
|
|
|
21
20
|
* all components
|
|
22
21
|
*/
|
|
23
22
|
interface AUTHSTATE {
|
|
24
|
-
|
|
23
|
+
UID?: string
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
interface AUTHACTION {
|
|
28
27
|
type: AUTHACTIONTYPE,
|
|
29
|
-
payload:
|
|
28
|
+
payload: string | undefined
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
|
|
@@ -34,16 +33,16 @@ const initialAUTHState: AUTHSTATE = {}
|
|
|
34
33
|
|
|
35
34
|
const AUTHReducer = (state: AUTHSTATE, action: AUTHACTION): AUTHSTATE => {
|
|
36
35
|
switch (action.type) {
|
|
37
|
-
case AUTHACTIONTYPE.
|
|
36
|
+
case AUTHACTIONTYPE.SETUID: {
|
|
38
37
|
const nextUser = action.payload;
|
|
39
38
|
|
|
40
|
-
if (state.
|
|
39
|
+
if (state.UID === nextUser) {
|
|
41
40
|
return state;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
return {
|
|
45
44
|
...state,
|
|
46
|
-
|
|
45
|
+
UID: nextUser,
|
|
47
46
|
};
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -74,24 +73,13 @@ export const AUTHProvider = ({ children, auth }: AUTHProviderProps) => {
|
|
|
74
73
|
);
|
|
75
74
|
|
|
76
75
|
useEffect(() => {
|
|
77
|
-
const unsubscribe = onAuthStateChanged(
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
dispatch({
|
|
86
|
-
type: AUTHACTIONTYPE.SETFBUSER,
|
|
87
|
-
payload: authUser ?? undefined,
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
} catch (error) {
|
|
91
|
-
errorLogger('User Authentication error:', error);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
);
|
|
76
|
+
const unsubscribe = onAuthStateChanged(auth, (authUser) => {
|
|
77
|
+
|
|
78
|
+
dispatch({
|
|
79
|
+
type: AUTHACTIONTYPE.SETUID,
|
|
80
|
+
payload: authUser?.uid ?? undefined,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
95
83
|
|
|
96
84
|
return unsubscribe;
|
|
97
85
|
}, []);
|