@ebubekirylmaz/link-test 1.2.21 → 1.2.23

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/index.js CHANGED
@@ -1,3 +1 @@
1
1
  export { default as Platform } from "./src/Platform";
2
-
3
- import "./src/widgets/Login/amplifyAuth";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebubekirylmaz/link-test",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
package/src/Platform.jsx CHANGED
@@ -1,4 +1,9 @@
1
1
  import "./global.css";
2
+ import "./widgets/Login/amplifyAuth";
3
+
4
+ import { BrowserRouter, Navigate } from "react-router-dom";
5
+ import { initialState, reducer } from "./context/reducer";
6
+ import { publish, subscribe, useEvent } from "@nucleoidai/react-event";
2
7
 
3
8
  import ContextProvider from "./ContextProvider/ContextProvider";
4
9
  import GlobalSnackMessage from "./GlobalSnackMessage/GlobalSnackMessage";
@@ -13,10 +18,6 @@ import http from "./http";
13
18
  import { init } from "./config/config";
14
19
  import oauth from "./http/oauth";
15
20
 
16
- import { BrowserRouter, Navigate } from "react-router-dom";
17
- import { initialState, reducer } from "./context/reducer";
18
- import { publish, subscribe, useEvent } from "@nucleoidai/react-event";
19
-
20
21
  init();
21
22
 
22
23
  window["@nucleoidai"] = {
@@ -1,12 +1,18 @@
1
1
  import { fetchAuthSession, signIn } from "aws-amplify/auth";
2
2
 
3
+ import { ensureAmplifyAuth } from "./amplifyAuth";
4
+
3
5
  export async function loginWithAmplify(username, password) {
6
+ const ready = ensureAmplifyAuth();
7
+ if (!ready) {
8
+ throw new Error("Auth not ready yet. Please try again.");
9
+ }
10
+
4
11
  const result = await signIn({
5
12
  username,
6
13
  password,
7
14
  });
8
15
 
9
- // Handle challenges (MFA, new password, etc.)
10
16
  if (result.nextStep?.signInStep !== "DONE") {
11
17
  return {
12
18
  challenge: result.nextStep.signInStep,
@@ -1,19 +1,28 @@
1
1
  import { Amplify } from "aws-amplify";
2
2
  import config from "../../config/config";
3
3
 
4
- const { credentials } = config();
4
+ let initialized = false;
5
5
 
6
- if (!credentials) {
7
- throw new Error("Cognito credentials not initialized");
8
- }
6
+ export function ensureAmplifyAuth() {
7
+ if (initialized) return;
8
+
9
+ const { credentials } = config();
10
+ if (!credentials) {
11
+ // 👈 do NOT throw here
12
+ return false;
13
+ }
9
14
 
10
- Amplify.configure({
11
- Auth: {
12
- region: credentials.region,
13
- userPoolId: credentials.userPoolId,
14
- userPoolWebClientId: credentials.clientId,
15
- authenticationFlowType: "USER_SRP_AUTH",
16
- },
17
- });
15
+ Amplify.configure({
16
+ Auth: {
17
+ region: credentials.region,
18
+ userPoolId: credentials.userPoolId,
19
+ userPoolWebClientId: credentials.clientId,
20
+ authenticationFlowType: "USER_SRP_AUTH",
21
+ oauth: undefined, // disable Hosted UI
22
+ },
23
+ });
18
24
 
19
- console.log("✅ Amplify Auth configured");
25
+ initialized = true;
26
+ console.log("✅ Amplify Auth configured");
27
+ return true;
28
+ }