@ebubekirylmaz/link-test 1.2.35 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebubekirylmaz/link-test",
3
- "version": "1.2.35",
3
+ "version": "1.2.37",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -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", "accessToken");
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,34 +17,29 @@ export default function CognitoLogin() {
17
17
 
18
18
  const handleLogin = async () => {
19
19
  try {
20
- // 1️⃣ Login with Cognito
21
20
  await login(username, password);
22
21
 
23
- // 2️⃣ Get Cognito tokens
24
22
  const tokens = await getTokens();
25
-
26
- if (!tokens?.accessToken) {
23
+ if (!tokens?.accessToken)
27
24
  throw new Error("No Cognito access token received");
28
- }
25
+
26
+ storage.set("link", "cognitoRefresh", tokens.accessToken);
29
27
 
30
28
  const res = await fetch("/api/oauth", {
31
29
  method: "POST",
32
30
  headers: { "Content-Type": "application/json" },
33
31
  body: JSON.stringify({
34
- appId: appId,
32
+ appId,
35
33
  projectId: "cb16e069-6214-47f1-9922-1f7fe7629525",
36
34
  identityProvider: "COGNITO",
37
- refreshToken: tokens.accessToken, // 🔥 Cognito ACCESS token
35
+ refreshToken: tokens.accessToken,
38
36
  }),
39
37
  });
40
38
 
41
- if (!res.ok) {
42
- throw new Error("Backend OAuth exchange failed");
43
- }
39
+ if (!res.ok) throw new Error("Backend OAuth exchange failed");
44
40
 
45
41
  const data = await res.json();
46
42
 
47
- // 4️⃣ Store INTERNAL tokens (same as Demo)
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
- }