react-redux-django-auth 1.3.1 → 1.3.3
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/index.d.mts +34 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +46 -5
- package/dist/index.mjs +31 -11
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -112,4 +112,37 @@ type AuthProviderProps = {
|
|
|
112
112
|
};
|
|
113
113
|
declare const AuthProvider: React$1.FC<AuthProviderProps>;
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
/**
|
|
116
|
+
* A type representing a single error message string.
|
|
117
|
+
*/
|
|
118
|
+
type ErrorMessage = string;
|
|
119
|
+
/**
|
|
120
|
+
* A type representing an array of error messages.
|
|
121
|
+
*/
|
|
122
|
+
type ErrorMessageArray = string[];
|
|
123
|
+
/**
|
|
124
|
+
* A type representing an object where keys map to either a single error message
|
|
125
|
+
* or an array of error messages.
|
|
126
|
+
*/
|
|
127
|
+
type ErrorMessageObject = {
|
|
128
|
+
[key: string]: ErrorMessage | ErrorMessageArray;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* A union type for all possible error message inputs.
|
|
132
|
+
*/
|
|
133
|
+
type ErrorMessageType = ErrorMessage | ErrorMessageArray | ErrorMessageObject;
|
|
134
|
+
/**
|
|
135
|
+
* Extracts and flattens various error message formats into a single array of strings.
|
|
136
|
+
*
|
|
137
|
+
* This function can handle:
|
|
138
|
+
* - A single string: Returns an array with that string.
|
|
139
|
+
* - An array of strings: Returns the array as is.
|
|
140
|
+
* - An object: Iterates through the object's values and extracts all strings
|
|
141
|
+
* and strings from arrays into a single flattened array.
|
|
142
|
+
*
|
|
143
|
+
* @param errorMsg The error message(s) to extract, which can be a string, array, or object.
|
|
144
|
+
* @returns A flattened array of error message strings.
|
|
145
|
+
*/
|
|
146
|
+
declare const extractErrorMessages: (errorMsg: ErrorMessageType) => string[];
|
|
147
|
+
|
|
148
|
+
export { AuthProvider, extractErrorMessages, useActivate, useAuthicatedUser, useChangeAuthenticatedUserPassword, useFacebookAuth, useGoogleAuth, useLogin, useLogout, usePasswordConfirm, useResetPassword, useSignup };
|
package/dist/index.d.ts
CHANGED
|
@@ -112,4 +112,37 @@ type AuthProviderProps = {
|
|
|
112
112
|
};
|
|
113
113
|
declare const AuthProvider: React$1.FC<AuthProviderProps>;
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
/**
|
|
116
|
+
* A type representing a single error message string.
|
|
117
|
+
*/
|
|
118
|
+
type ErrorMessage = string;
|
|
119
|
+
/**
|
|
120
|
+
* A type representing an array of error messages.
|
|
121
|
+
*/
|
|
122
|
+
type ErrorMessageArray = string[];
|
|
123
|
+
/**
|
|
124
|
+
* A type representing an object where keys map to either a single error message
|
|
125
|
+
* or an array of error messages.
|
|
126
|
+
*/
|
|
127
|
+
type ErrorMessageObject = {
|
|
128
|
+
[key: string]: ErrorMessage | ErrorMessageArray;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* A union type for all possible error message inputs.
|
|
132
|
+
*/
|
|
133
|
+
type ErrorMessageType = ErrorMessage | ErrorMessageArray | ErrorMessageObject;
|
|
134
|
+
/**
|
|
135
|
+
* Extracts and flattens various error message formats into a single array of strings.
|
|
136
|
+
*
|
|
137
|
+
* This function can handle:
|
|
138
|
+
* - A single string: Returns an array with that string.
|
|
139
|
+
* - An array of strings: Returns the array as is.
|
|
140
|
+
* - An object: Iterates through the object's values and extracts all strings
|
|
141
|
+
* and strings from arrays into a single flattened array.
|
|
142
|
+
*
|
|
143
|
+
* @param errorMsg The error message(s) to extract, which can be a string, array, or object.
|
|
144
|
+
* @returns A flattened array of error message strings.
|
|
145
|
+
*/
|
|
146
|
+
declare const extractErrorMessages: (errorMsg: ErrorMessageType) => string[];
|
|
147
|
+
|
|
148
|
+
export { AuthProvider, extractErrorMessages, useActivate, useAuthicatedUser, useChangeAuthenticatedUserPassword, useFacebookAuth, useGoogleAuth, useLogin, useLogout, usePasswordConfirm, useResetPassword, useSignup };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@ function _array_like_to_array(arr, len) {
|
|
|
7
7
|
function _array_with_holes(arr) {
|
|
8
8
|
if (Array.isArray(arr)) return arr;
|
|
9
9
|
}
|
|
10
|
+
function _array_without_holes(arr) {
|
|
11
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
12
|
+
}
|
|
10
13
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
14
|
try {
|
|
12
15
|
var info = gen[key](arg);
|
|
@@ -49,6 +52,9 @@ function _define_property(obj, key, value) {
|
|
|
49
52
|
}
|
|
50
53
|
return obj;
|
|
51
54
|
}
|
|
55
|
+
function _iterable_to_array(iter) {
|
|
56
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
57
|
+
}
|
|
52
58
|
function _iterable_to_array_limit(arr, i) {
|
|
53
59
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
54
60
|
if (_i == null) return;
|
|
@@ -76,6 +82,9 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
76
82
|
function _non_iterable_rest() {
|
|
77
83
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
78
84
|
}
|
|
85
|
+
function _non_iterable_spread() {
|
|
86
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
87
|
+
}
|
|
79
88
|
function _object_spread(target) {
|
|
80
89
|
for(var i = 1; i < arguments.length; i++){
|
|
81
90
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -118,6 +127,9 @@ function _object_spread_props(target, source) {
|
|
|
118
127
|
function _sliced_to_array(arr, i) {
|
|
119
128
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
120
129
|
}
|
|
130
|
+
function _to_consumable_array(arr) {
|
|
131
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
132
|
+
}
|
|
121
133
|
function _type_of(obj) {
|
|
122
134
|
"@swc/helpers - typeof";
|
|
123
135
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -285,6 +297,9 @@ __export(src_exports, {
|
|
|
285
297
|
AuthProvider: function() {
|
|
286
298
|
return app_default;
|
|
287
299
|
},
|
|
300
|
+
extractErrorMessages: function() {
|
|
301
|
+
return extractErrorMessages;
|
|
302
|
+
},
|
|
288
303
|
useActivate: function() {
|
|
289
304
|
return useActivate_default;
|
|
290
305
|
},
|
|
@@ -1007,10 +1022,10 @@ var useActivate = function(uid, token, apiUrl) {
|
|
|
1007
1022
|
var _ref = _sliced_to_array((0, import_react.useState)(false), 2), loading = _ref[0], setLoading = _ref[1];
|
|
1008
1023
|
var dispatch = (0, import_react_redux.useDispatch)();
|
|
1009
1024
|
var error = (0, import_react_redux.useSelector)(function(state) {
|
|
1010
|
-
return state.error;
|
|
1025
|
+
return state.auth.error;
|
|
1011
1026
|
});
|
|
1012
1027
|
var status = (0, import_react_redux.useSelector)(function(state) {
|
|
1013
|
-
return state.status;
|
|
1028
|
+
return state.auth.status;
|
|
1014
1029
|
});
|
|
1015
1030
|
var isStatus204 = status === 204;
|
|
1016
1031
|
(0, import_react.useEffect)(function() {
|
|
@@ -1192,13 +1207,13 @@ var useSignup = function(initialFields, apiUrl) {
|
|
|
1192
1207
|
var _ref1 = _sliced_to_array((0, import_react4.useState)(initialFields), 2), formData = _ref1[0], setFormData = _ref1[1];
|
|
1193
1208
|
var dispatch = (0, import_react_redux4.useDispatch)();
|
|
1194
1209
|
var isAuthenticated = (0, import_react_redux4.useSelector)(function(state) {
|
|
1195
|
-
return state.isAuthenticated;
|
|
1210
|
+
return state.auth.isAuthenticated;
|
|
1196
1211
|
});
|
|
1197
1212
|
var error = (0, import_react_redux4.useSelector)(function(state) {
|
|
1198
|
-
return state.error;
|
|
1213
|
+
return state.auth.error;
|
|
1199
1214
|
});
|
|
1200
1215
|
var status = (0, import_react_redux4.useSelector)(function(state) {
|
|
1201
|
-
return state.status;
|
|
1216
|
+
return state.auth.status;
|
|
1202
1217
|
});
|
|
1203
1218
|
var isStatus201 = status === 201;
|
|
1204
1219
|
(0, import_react4.useEffect)(function() {
|
|
@@ -1996,9 +2011,35 @@ var AuthProvider = function(param) {
|
|
|
1996
2011
|
}, children);
|
|
1997
2012
|
};
|
|
1998
2013
|
var app_default = AuthProvider;
|
|
2014
|
+
// src/utils/ExtractErrorMsg.tsx
|
|
2015
|
+
var extractErrorMessages = function(errorMsg) {
|
|
2016
|
+
if (typeof errorMsg === "string") {
|
|
2017
|
+
return [
|
|
2018
|
+
errorMsg
|
|
2019
|
+
];
|
|
2020
|
+
}
|
|
2021
|
+
if (Array.isArray(errorMsg)) {
|
|
2022
|
+
return errorMsg;
|
|
2023
|
+
}
|
|
2024
|
+
if ((typeof errorMsg === "undefined" ? "undefined" : _type_of(errorMsg)) === "object" && errorMsg !== null) {
|
|
2025
|
+
var extractedMessages = [];
|
|
2026
|
+
Object.keys(errorMsg).forEach(function(key) {
|
|
2027
|
+
var value = errorMsg[key];
|
|
2028
|
+
if (Array.isArray(value)) {
|
|
2029
|
+
var _extractedMessages;
|
|
2030
|
+
(_extractedMessages = extractedMessages).push.apply(_extractedMessages, _to_consumable_array(value));
|
|
2031
|
+
} else if (typeof value === "string") {
|
|
2032
|
+
extractedMessages.push(value);
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2035
|
+
return extractedMessages;
|
|
2036
|
+
}
|
|
2037
|
+
return [];
|
|
2038
|
+
};
|
|
1999
2039
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2000
2040
|
0 && (module.exports = {
|
|
2001
2041
|
AuthProvider: AuthProvider,
|
|
2042
|
+
extractErrorMessages: extractErrorMessages,
|
|
2002
2043
|
useActivate: useActivate,
|
|
2003
2044
|
useAuthicatedUser: useAuthicatedUser,
|
|
2004
2045
|
useChangeAuthenticatedUserPassword: useChangeAuthenticatedUserPassword,
|
package/dist/index.mjs
CHANGED
|
@@ -314,8 +314,8 @@ var changeLoggedInUserPassword = (formData, apiUrl) => async (dispatch) => {
|
|
|
314
314
|
var useActivate = (uid, token, apiUrl) => {
|
|
315
315
|
const [loading, setLoading] = useState(false);
|
|
316
316
|
const dispatch = useDispatch();
|
|
317
|
-
const error = useSelector((state) => state.error);
|
|
318
|
-
const status = useSelector((state) => state.status);
|
|
317
|
+
const error = useSelector((state) => state.auth.error);
|
|
318
|
+
const status = useSelector((state) => state.auth.status);
|
|
319
319
|
const isStatus204 = status === 204;
|
|
320
320
|
useEffect(() => {
|
|
321
321
|
return () => {
|
|
@@ -414,10 +414,10 @@ var useSignup = (initialFields, apiUrl) => {
|
|
|
414
414
|
const [formData, setFormData] = useState3(initialFields);
|
|
415
415
|
const dispatch = useDispatch4();
|
|
416
416
|
const isAuthenticated = useSelector3(
|
|
417
|
-
(state) => state.isAuthenticated
|
|
417
|
+
(state) => state.auth.isAuthenticated
|
|
418
418
|
);
|
|
419
|
-
const error = useSelector3((state) => state.error);
|
|
420
|
-
const status = useSelector3((state) => state.status);
|
|
419
|
+
const error = useSelector3((state) => state.auth.error);
|
|
420
|
+
const status = useSelector3((state) => state.auth.status);
|
|
421
421
|
const isStatus201 = status === 201;
|
|
422
422
|
useEffect3(() => {
|
|
423
423
|
return () => {
|
|
@@ -464,9 +464,7 @@ var useAuthicatedUser = (apiURL, location) => {
|
|
|
464
464
|
(state) => state.auth.isAuthenticated
|
|
465
465
|
);
|
|
466
466
|
const error = useSelector4((state) => state.auth.error);
|
|
467
|
-
const currentUser = useSelector4(
|
|
468
|
-
(state) => state.auth.user
|
|
469
|
-
);
|
|
467
|
+
const currentUser = useSelector4((state) => state.auth.user);
|
|
470
468
|
useEffect4(() => {
|
|
471
469
|
dispatch(checkAuthenticated(apiURL));
|
|
472
470
|
}, [dispatch, apiURL, location]);
|
|
@@ -593,9 +591,7 @@ var useChangeAuthenticatedUserPassword = (initialFields, apiUrl) => {
|
|
|
593
591
|
const [loading, setLoading] = useState6(false);
|
|
594
592
|
const [formData, setFormData] = useState6(initialFields);
|
|
595
593
|
const [error, setError] = useState6(null);
|
|
596
|
-
const authError = useSelector7(
|
|
597
|
-
(state) => state.auth.error
|
|
598
|
-
);
|
|
594
|
+
const authError = useSelector7((state) => state.auth.error);
|
|
599
595
|
const status = useSelector7((state) => state.auth.status);
|
|
600
596
|
useEffect7(() => {
|
|
601
597
|
return () => {
|
|
@@ -875,8 +871,32 @@ var AuthProvider = ({ children }) => {
|
|
|
875
871
|
return /* @__PURE__ */ React.createElement(Provider, { store: store_default }, children);
|
|
876
872
|
};
|
|
877
873
|
var app_default = AuthProvider;
|
|
874
|
+
|
|
875
|
+
// src/utils/ExtractErrorMsg.tsx
|
|
876
|
+
var extractErrorMessages = (errorMsg) => {
|
|
877
|
+
if (typeof errorMsg === "string") {
|
|
878
|
+
return [errorMsg];
|
|
879
|
+
}
|
|
880
|
+
if (Array.isArray(errorMsg)) {
|
|
881
|
+
return errorMsg;
|
|
882
|
+
}
|
|
883
|
+
if (typeof errorMsg === "object" && errorMsg !== null) {
|
|
884
|
+
const extractedMessages = [];
|
|
885
|
+
Object.keys(errorMsg).forEach((key) => {
|
|
886
|
+
const value = errorMsg[key];
|
|
887
|
+
if (Array.isArray(value)) {
|
|
888
|
+
extractedMessages.push(...value);
|
|
889
|
+
} else if (typeof value === "string") {
|
|
890
|
+
extractedMessages.push(value);
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
return extractedMessages;
|
|
894
|
+
}
|
|
895
|
+
return [];
|
|
896
|
+
};
|
|
878
897
|
export {
|
|
879
898
|
app_default as AuthProvider,
|
|
899
|
+
extractErrorMessages,
|
|
880
900
|
useActivate_default as useActivate,
|
|
881
901
|
useLoadUser_default as useAuthicatedUser,
|
|
882
902
|
useChangePassword_default as useChangeAuthenticatedUserPassword,
|