@ebubekirylmaz/link-test 1.0.0 → 1.1.1

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.0.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "exports": {
@@ -3,10 +3,9 @@ import {
3
3
  MenuConfigSchema,
4
4
  TemplateConfigSchema,
5
5
  } from "./schemas.js";
6
-
7
- import configMain from "/Users/ebubekiryilmaz/Documents/greycollar/dashboard/config.js";
8
- import configMenu from "/Users/ebubekiryilmaz/Documents/greycollar/dashboard/config.menu.js";
9
- import configTemplate from "/Users/ebubekiryilmaz/Documents/greycollar/dashboard/config.template.js";
6
+ import configMain from "../../../../../config.js";
7
+ import configMenu from "../../../../../config.menu.js";
8
+ import configTemplate from "../../../../../config.template.js";
10
9
  import { publish } from "@nucleoidai/react-event";
11
10
 
12
11
  let _mainConfig = {};
@@ -1,10 +1,10 @@
1
- import { Card, Tooltip, Typography } from "@mui/material";
2
-
3
1
  import AnimatedNode from "./AnimatedNode";
4
- import Iconify from "../../Iconify/index";
2
+ import { Iconify } from "@canmingir/link/platform/components";
5
3
  import LoadingNode from "./LoadingNode";
6
4
  import React from "react";
7
5
 
6
+ import { Card, Tooltip, Typography } from "@mui/material";
7
+
8
8
  const ActionNode = ({
9
9
  visible,
10
10
  delay,
@@ -1,8 +1,8 @@
1
+ import { Iconify } from "@canmingir/link/platform/components";
2
+
1
3
  import React, { useEffect, useState } from "react";
2
4
  import { alpha, styled } from "@mui/material/styles";
3
5
 
4
- import Iconify from "../../Iconify/index";
5
-
6
6
  const ANIMATION_DELAY_MS = 200;
7
7
 
8
8
  const MainContainer = styled("div", {
@@ -1,4 +1,5 @@
1
1
  import { loginWithCognito } from "./cognitoAuth";
2
+ import { storage } from "@nucleoidjs/webstorage";
2
3
  import { useState } from "react";
3
4
 
4
5
  import { Button, Stack, TextField, Typography } from "@mui/material";
@@ -10,12 +11,13 @@ export default function CognitoLogin() {
10
11
  const handleLogin = async () => {
11
12
  try {
12
13
  const tokens = await loginWithCognito(username, password);
13
- console.log(tokens);
14
- localStorage.setItem("link", "accessToken", tokens.AccessToken);
15
- localStorage.setItem("link", "refreshToken", tokens.RefreshToken);
14
+ console.log("Login successful, tokens:", tokens);
15
+ storage.set("link", "accessToken", tokens.AccessToken);
16
+ storage.set("link", "refreshToken", tokens.RefreshToken);
16
17
  window.location.href = "/";
17
18
  } catch (e) {
18
- alert("Login failed");
19
+ console.error("Login error:", e);
20
+ alert(`Login failed: ${e.message || e}`);
19
21
  }
20
22
  };
21
23
 
@@ -1,17 +1,35 @@
1
+ import config from "../../config/config";
2
+
1
3
  import {
2
4
  CognitoIdentityProviderClient,
3
5
  InitiateAuthCommand,
4
6
  } from "@aws-sdk/client-cognito-identity-provider";
5
7
 
6
- import config from "../../config/config";
8
+ let client = null;
9
+
10
+ function getClient() {
11
+ if (!client) {
12
+ const { credentials } = config();
13
+ if (!credentials) {
14
+ throw new Error("Cognito credentials not initialized yet");
15
+ }
7
16
 
8
- const { credentials } = config();
17
+ client = new CognitoIdentityProviderClient({
18
+ region: credentials.region,
19
+ });
9
20
 
10
- const client = new CognitoIdentityProviderClient({
11
- region: credentials?.region,
12
- });
21
+ console.log("Initialized Cognito Client with region:", credentials.region);
22
+ }
23
+
24
+ return client;
25
+ }
13
26
 
14
27
  export async function loginWithCognito(username, password) {
28
+ const { credentials } = config();
29
+ if (!credentials) {
30
+ throw new Error("CONFIG not initialized yet. Wait for CONFIG_INITIALIZED.");
31
+ }
32
+
15
33
  const command = new InitiateAuthCommand({
16
34
  AuthFlow: "USER_PASSWORD_AUTH",
17
35
  ClientId: credentials.clientId,
@@ -21,6 +39,6 @@ export async function loginWithCognito(username, password) {
21
39
  },
22
40
  });
23
41
 
24
- const response = await client.send(command);
42
+ const response = await getClient().send(command);
25
43
  return response.AuthenticationResult;
26
44
  }
package/vite/vite.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { ConfigSchema } from "../src/config/schemas.js";
2
2
  import checker from "vite-plugin-checker";
3
- import config from "/Users/ebubekiryilmaz/Documents/greycollar/dashboard/config.js";
3
+ import config from "../../../../config.js";
4
4
  import path from "path";
5
5
  import react from "@vitejs/plugin-react";
6
- // import { splitVendorChunkPlugin } from "vite";
6
+ import { splitVendorChunkPlugin } from "vite";
7
7
  import svgr from "vite-plugin-svgr";
8
8
 
9
9
  const { value, error } = ConfigSchema.validate(config);
@@ -18,7 +18,7 @@ async function vite() {
18
18
 
19
19
  return {
20
20
  plugins: [
21
- // splitVendorChunkPlugin(),
21
+ splitVendorChunkPlugin(),
22
22
  react(),
23
23
  svgr(),
24
24
  checker({