@ttoss/react-auth 1.7.39 → 1.7.41
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/esm/index.js +7 -9
- package/package.json +13 -13
- package/src/AuthProvider.tsx +10 -8
package/dist/esm/index.js
CHANGED
|
@@ -29,22 +29,20 @@ var AuthProvider = ({
|
|
|
29
29
|
React.useEffect(() => {
|
|
30
30
|
const updateUser = () => {
|
|
31
31
|
getCurrentUser().then(async ({
|
|
32
|
-
userId
|
|
33
|
-
username
|
|
32
|
+
userId
|
|
34
33
|
}) => {
|
|
35
|
-
const session = await fetchAuthSession();
|
|
36
|
-
const idToken = session.tokens?.idToken?.toString();
|
|
37
|
-
const accessToken = session.tokens?.accessToken.toString();
|
|
38
|
-
const user2 = await fetchUserAttributes();
|
|
34
|
+
const [session, user2] = await Promise.all([fetchAuthSession(), fetchUserAttributes()]);
|
|
35
|
+
const idToken = session.tokens?.idToken?.toString() ?? "";
|
|
36
|
+
const accessToken = session.tokens?.accessToken.toString() ?? "";
|
|
39
37
|
setAuthState({
|
|
40
38
|
user: {
|
|
41
39
|
id: userId,
|
|
42
|
-
email:
|
|
40
|
+
email: user2.email ?? "",
|
|
43
41
|
emailVerified: user2.email_verified ?? ""
|
|
44
42
|
},
|
|
45
43
|
tokens: {
|
|
46
|
-
idToken
|
|
47
|
-
accessToken
|
|
44
|
+
idToken,
|
|
45
|
+
accessToken,
|
|
48
46
|
refreshToken: ""
|
|
49
47
|
},
|
|
50
48
|
isAuthenticated: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-auth",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.41",
|
|
4
4
|
"description": "ttoss authentication module for React apps.",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -27,28 +27,28 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@xstate/react": "^3.2.2",
|
|
29
29
|
"xstate": "^4.38.3",
|
|
30
|
-
"@ttoss/forms": "^0.23.
|
|
30
|
+
"@ttoss/forms": "^0.23.3"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"aws-amplify": "^6.0.0",
|
|
34
34
|
"react": ">=16.8.0",
|
|
35
|
-
"@ttoss/react-i18n": "^1.26.
|
|
36
|
-
"@ttoss/react-notifications": "^1.24.
|
|
37
|
-
"@ttoss/ui": "^4.1.
|
|
35
|
+
"@ttoss/react-i18n": "^1.26.3",
|
|
36
|
+
"@ttoss/react-notifications": "^1.24.35",
|
|
37
|
+
"@ttoss/ui": "^4.1.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/globals": "^29.7.0",
|
|
41
|
-
"@types/react": "^18.2.
|
|
42
|
-
"aws-amplify": "^6.0.
|
|
41
|
+
"@types/react": "^18.2.76",
|
|
42
|
+
"aws-amplify": "^6.0.28",
|
|
43
43
|
"jest": "^29.7.0",
|
|
44
44
|
"tsup": "^8.0.2",
|
|
45
|
-
"@ttoss/cloud-auth": "^0.12.
|
|
45
|
+
"@ttoss/cloud-auth": "^0.12.3",
|
|
46
46
|
"@ttoss/config": "^1.31.5",
|
|
47
|
-
"@ttoss/i18n
|
|
48
|
-
"@ttoss/react-
|
|
49
|
-
"@ttoss/
|
|
50
|
-
"@ttoss/test-utils": "^2.1.
|
|
51
|
-
"@ttoss/ui": "^4.1.
|
|
47
|
+
"@ttoss/react-i18n": "^1.26.3",
|
|
48
|
+
"@ttoss/react-notifications": "^1.24.35",
|
|
49
|
+
"@ttoss/i18n-cli": "^0.7.7",
|
|
50
|
+
"@ttoss/test-utils": "^2.1.2",
|
|
51
|
+
"@ttoss/ui": "^4.1.5"
|
|
52
52
|
},
|
|
53
53
|
"keywords": [
|
|
54
54
|
"React",
|
package/src/AuthProvider.tsx
CHANGED
|
@@ -50,22 +50,24 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|
|
50
50
|
React.useEffect(() => {
|
|
51
51
|
const updateUser = () => {
|
|
52
52
|
getCurrentUser()
|
|
53
|
-
.then(async ({ userId
|
|
54
|
-
const session = await
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
.then(async ({ userId }) => {
|
|
54
|
+
const [session, user] = await Promise.all([
|
|
55
|
+
fetchAuthSession(),
|
|
56
|
+
fetchUserAttributes(),
|
|
57
|
+
]);
|
|
57
58
|
|
|
58
|
-
const
|
|
59
|
+
const idToken = session.tokens?.idToken?.toString() ?? '';
|
|
60
|
+
const accessToken = session.tokens?.accessToken.toString() ?? '';
|
|
59
61
|
|
|
60
62
|
setAuthState({
|
|
61
63
|
user: {
|
|
62
64
|
id: userId,
|
|
63
|
-
email:
|
|
65
|
+
email: user.email ?? '',
|
|
64
66
|
emailVerified: user.email_verified ?? '',
|
|
65
67
|
},
|
|
66
68
|
tokens: {
|
|
67
|
-
idToken
|
|
68
|
-
accessToken
|
|
69
|
+
idToken,
|
|
70
|
+
accessToken,
|
|
69
71
|
refreshToken: '',
|
|
70
72
|
},
|
|
71
73
|
isAuthenticated: true,
|