@ebubekirylmaz/link-test 1.2.17 → 1.2.19

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 +1,3 @@
1
1
  export { default as Platform } from "./src/Platform";
2
+
3
+ import "./auth/amplifyAuth";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebubekirylmaz/link-test",
3
- "version": "1.2.17",
3
+ "version": "1.2.19",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -1,26 +1,24 @@
1
- import { Auth } from "aws-amplify";
2
- import { initAmplifyAuth } from "./amplifyAuth";
1
+ import { fetchAuthSession, signIn } from "aws-amplify/auth";
3
2
 
4
3
  export async function loginWithAmplify(username, password) {
5
- console.log(Auth.configure());
4
+ const result = await signIn({
5
+ username,
6
+ password,
7
+ });
6
8
 
7
- initAmplifyAuth();
8
-
9
- const user = await Auth.signIn(username, password);
10
-
11
- // Handle challenges if needed
12
- if (user.challengeName) {
9
+ // Handle challenges (MFA, new password, etc.)
10
+ if (result.nextStep?.signInStep !== "DONE") {
13
11
  return {
14
- challenge: user.challengeName,
15
- user,
12
+ challenge: result.nextStep.signInStep,
13
+ result,
16
14
  };
17
15
  }
18
16
 
19
- const session = user.signInUserSession;
17
+ const session = await fetchAuthSession();
20
18
 
21
19
  return {
22
- AccessToken: session.accessToken.jwtToken,
23
- IdToken: session.idToken.jwtToken,
24
- RefreshToken: session.refreshToken.token,
20
+ AccessToken: session.tokens?.accessToken?.toString(),
21
+ IdToken: session.tokens?.idToken?.toString(),
22
+ RefreshToken: session.tokens?.refreshToken?.toString(),
25
23
  };
26
24
  }