@pubflow/core 0.4.4 → 0.4.5

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.
@@ -49,16 +49,21 @@ class AuthService {
49
49
  console.log('AuthService.login: Login successful, storing session data');
50
50
  }
51
51
  const data = response.data;
52
- // Normalize snake_case → camelCase for 2FA fields returned by the backend
53
- // Backend: { requires_2fa, session_id, available_methods }
54
- // Client expects: { requires2fa, sessionId, availableMethods }
52
+ // Normalize snake_case → camelCase for 2FA fields returned by the backend.
53
+ // Backend: { success:false, requires_2fa:true, session_id, available_methods, user }
55
54
  if (data.requires_2fa) {
56
55
  const partialSessionId = (_b = data.session_id) !== null && _b !== void 0 ? _b : data.sessionId;
57
- // CRITICAL: store the partial session so ApiClient can attach it
58
- // to subsequent /auth/two_factor/:method/start calls.
56
+ // Store the partial session so ApiClient can attach it on
57
+ // subsequent /auth/two_factor/:method/start and /verify calls.
59
58
  if (partialSessionId) {
60
59
  await this.storage.setItem(this.sessionKey, partialSessionId);
61
60
  }
61
+ // The 2FA login response already includes safe user data.
62
+ // Store it now so getCurrentUser() returns the real user after OTP verify —
63
+ // no extra API call to /me or /validation needed.
64
+ if (data.user) {
65
+ await this.storeUserData(data.user);
66
+ }
62
67
  return {
63
68
  success: true,
64
69
  requires2fa: true,
@@ -66,7 +71,7 @@ class AuthService {
66
71
  availableMethods: (_d = (_c = data.available_methods) !== null && _c !== void 0 ? _c : data.availableMethods) !== null && _d !== void 0 ? _d : [],
67
72
  };
68
73
  }
69
- // Normal login — store session ID and user data
74
+ // Normal (non-2FA) login — store session ID and user data
70
75
  if ((_e = data.session_id) !== null && _e !== void 0 ? _e : data.sessionId) {
71
76
  await this.storage.setItem(this.sessionKey, (_f = data.session_id) !== null && _f !== void 0 ? _f : data.sessionId);
72
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pubflow/core",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Core functionality for Pubflow framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",