@pubflow/core 0.4.4 → 0.4.6
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/dist/auth/service.js +11 -6
- package/dist/auth/two-factor.d.ts +1 -1
- package/dist/auth/two-factor.js +7 -2
- package/package.json +1 -1
package/dist/auth/service.js
CHANGED
|
@@ -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
|
-
//
|
|
58
|
-
//
|
|
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
|
}
|
|
@@ -11,7 +11,7 @@ import type { TwoFactorMethod, TwoFactorSystemInfo, TwoFactorStartResult, TwoFac
|
|
|
11
11
|
export declare class TwoFactorService {
|
|
12
12
|
private apiClient;
|
|
13
13
|
private basePath;
|
|
14
|
-
constructor(apiClient: ApiClient,
|
|
14
|
+
constructor(apiClient: ApiClient, configOrBasePath: PubflowInstanceConfig | string);
|
|
15
15
|
/**
|
|
16
16
|
* GET /auth/two_factor/system
|
|
17
17
|
* Returns system-level 2FA availability (no auth needed).
|
package/dist/auth/two-factor.js
CHANGED
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.TwoFactorService = void 0;
|
|
11
11
|
class TwoFactorService {
|
|
12
|
-
constructor(apiClient,
|
|
12
|
+
constructor(apiClient, configOrBasePath) {
|
|
13
13
|
this.apiClient = apiClient;
|
|
14
|
-
|
|
14
|
+
if (typeof configOrBasePath === 'string') {
|
|
15
|
+
this.basePath = configOrBasePath;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.basePath = `${configOrBasePath.authBasePath || '/auth'}/two_factor`;
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
// ─── Public (no auth) ──────────────────────────────────────────────────────
|
|
17
22
|
/**
|