@ebubekirylmaz/link-test 1.2.22 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebubekirylmaz/link-test",
3
- "version": "1.2.22",
3
+ "version": "1.2.23",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -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,22 +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;
9
8
 
10
- Amplify.configure({
11
- Auth: {
12
- region: credentials.region,
13
- userPoolId: credentials.userPoolId,
14
- userPoolWebClientId: credentials.clientId,
15
- authenticationFlowType: "USER_SRP_AUTH",
9
+ const { credentials } = config();
10
+ if (!credentials) {
11
+ // 👈 do NOT throw here
12
+ return false;
13
+ }
16
14
 
17
- // 🔴 IMPORTANT: explicitly disable OAuth / Hosted UI
18
- oauth: undefined,
19
- },
20
- });
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
+ });
21
24
 
22
- console.log("✅ Amplify Auth configured (SRP, no OAuth)");
25
+ initialized = true;
26
+ console.log("✅ Amplify Auth configured");
27
+ return true;
28
+ }