@ebubekirylmaz/link-test 1.2.36 → 1.2.37
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/package.json
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { Button, DialogActions } from "@mui/material";
|
|
2
|
-
import Dialog, { dialogClasses } from "@mui/material/Dialog";
|
|
3
|
-
import React, { useCallback, useState } from "react";
|
|
4
|
-
import { publish, useEvent } from "@nucleoidai/react-event";
|
|
5
|
-
import { storage, useStorage } from "@nucleoidjs/webstorage";
|
|
6
|
-
import { useMediaQuery, useTheme } from "@mui/material";
|
|
7
|
-
|
|
8
1
|
import Box from "@mui/material/Box";
|
|
9
2
|
import IconButton from "@mui/material/IconButton";
|
|
10
3
|
import Iconify from "../../../components/Iconify";
|
|
@@ -29,6 +22,13 @@ import { useEventListener } from "../../../hooks/use-event-listener";
|
|
|
29
22
|
import { useNavigate } from "react-router-dom";
|
|
30
23
|
import useProjects from "../../../hooks/useProjects";
|
|
31
24
|
|
|
25
|
+
import { Button, DialogActions } from "@mui/material";
|
|
26
|
+
import Dialog, { dialogClasses } from "@mui/material/Dialog";
|
|
27
|
+
import React, { useCallback, useState } from "react";
|
|
28
|
+
import { publish, useEvent } from "@nucleoidai/react-event";
|
|
29
|
+
import { storage, useStorage } from "@nucleoidjs/webstorage";
|
|
30
|
+
import { useMediaQuery, useTheme } from "@mui/material";
|
|
31
|
+
|
|
32
32
|
function ProjectBar() {
|
|
33
33
|
const label = config().template?.projectBar?.label;
|
|
34
34
|
const { appId } = config();
|
|
@@ -104,7 +104,7 @@ function ProjectBar() {
|
|
|
104
104
|
payload.username = "admin";
|
|
105
105
|
payload.password = "admin";
|
|
106
106
|
} else if (identityProvider === "COGNITO") {
|
|
107
|
-
payload.refreshToken = storage.get("link", "
|
|
107
|
+
payload.refreshToken = storage.get("link", "cognitoRefresh");
|
|
108
108
|
} else {
|
|
109
109
|
payload.refreshToken = storage.get("link", "refreshToken");
|
|
110
110
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Button, Stack, TextField, Typography } from "@mui/material";
|
|
2
|
-
import { confirmSignup, getTokens, login, signup } from "./amplifyAuth";
|
|
3
|
-
|
|
4
1
|
import config from "../../config/config";
|
|
5
2
|
import { storage } from "@nucleoidjs/webstorage";
|
|
6
3
|
import { useState } from "react";
|
|
7
4
|
|
|
5
|
+
import { Button, Stack, TextField, Typography } from "@mui/material";
|
|
6
|
+
import { confirmSignup, getTokens, login, signup } from "./amplifyAuth";
|
|
7
|
+
|
|
8
8
|
export default function CognitoLogin() {
|
|
9
9
|
const [mode, setMode] = useState("login");
|
|
10
10
|
|
|
@@ -17,18 +17,14 @@ export default function CognitoLogin() {
|
|
|
17
17
|
|
|
18
18
|
const handleLogin = async () => {
|
|
19
19
|
try {
|
|
20
|
-
// 1) Cognito sign-in (SRP handled by Amplify)
|
|
21
20
|
await login(username, password);
|
|
22
21
|
|
|
23
|
-
// 2) Get Cognito tokens
|
|
24
22
|
const tokens = await getTokens();
|
|
25
23
|
if (!tokens?.accessToken)
|
|
26
24
|
throw new Error("No Cognito access token received");
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
storage.set("link", "cognitoAccessToken", tokens.accessToken);
|
|
26
|
+
storage.set("link", "cognitoRefresh", tokens.accessToken);
|
|
30
27
|
|
|
31
|
-
// 3) Exchange Cognito token with YOUR backend
|
|
32
28
|
const res = await fetch("/api/oauth", {
|
|
33
29
|
method: "POST",
|
|
34
30
|
headers: { "Content-Type": "application/json" },
|
|
@@ -36,7 +32,7 @@ export default function CognitoLogin() {
|
|
|
36
32
|
appId,
|
|
37
33
|
projectId: "cb16e069-6214-47f1-9922-1f7fe7629525",
|
|
38
34
|
identityProvider: "COGNITO",
|
|
39
|
-
refreshToken: tokens.accessToken,
|
|
35
|
+
refreshToken: tokens.accessToken,
|
|
40
36
|
}),
|
|
41
37
|
});
|
|
42
38
|
|
|
@@ -44,7 +40,6 @@ export default function CognitoLogin() {
|
|
|
44
40
|
|
|
45
41
|
const data = await res.json();
|
|
46
42
|
|
|
47
|
-
// 4) Store INTERNAL tokens (issued by your backend)
|
|
48
43
|
storage.set("link", "accessToken", data.accessToken);
|
|
49
44
|
storage.set("link", "refreshToken", data.refreshToken);
|
|
50
45
|
storage.set("link", "identityProvider", "COGNITO");
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Amplify } from "aws-amplify";
|
|
2
|
-
import config from "../../config/config";
|
|
3
|
-
|
|
4
|
-
export function configureAmplify() {
|
|
5
|
-
const { credentials } = config();
|
|
6
|
-
|
|
7
|
-
if (!credentials) {
|
|
8
|
-
throw new Error("CONFIG not initialized yet");
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
Amplify.configure({
|
|
12
|
-
Auth: {
|
|
13
|
-
Cognito: {
|
|
14
|
-
userPoolId: credentials.userPoolId,
|
|
15
|
-
userPoolClientId: credentials.clientId,
|
|
16
|
-
region: credentials.region,
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
}
|