@insforge/sdk 1.0.8 → 1.1.0-dev.0
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/index.d.mts +0 -10
- package/dist/index.d.ts +0 -10
- package/dist/index.js +3 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -540,46 +540,6 @@ var Auth = class {
|
|
|
540
540
|
};
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
|
-
/**
|
|
544
|
-
* Get the current user with full profile information
|
|
545
|
-
* Returns both auth info (id, email, role) and profile data (dynamic fields from users table)
|
|
546
|
-
*/
|
|
547
|
-
async getCurrentUser() {
|
|
548
|
-
try {
|
|
549
|
-
const user = this.tokenManager.getUser();
|
|
550
|
-
if (user) {
|
|
551
|
-
return { data: { user }, error: null };
|
|
552
|
-
}
|
|
553
|
-
const accessToken = this.tokenManager.getAccessToken();
|
|
554
|
-
if (!accessToken) {
|
|
555
|
-
return { data: null, error: null };
|
|
556
|
-
}
|
|
557
|
-
this.http.setAuthToken(accessToken);
|
|
558
|
-
const authResponse = await this.http.get("/api/auth/sessions/current");
|
|
559
|
-
return {
|
|
560
|
-
data: {
|
|
561
|
-
user: authResponse.user
|
|
562
|
-
},
|
|
563
|
-
error: null
|
|
564
|
-
};
|
|
565
|
-
} catch (error) {
|
|
566
|
-
if (error instanceof InsForgeError && error.statusCode === 401) {
|
|
567
|
-
await this.signOut();
|
|
568
|
-
return { data: null, error: null };
|
|
569
|
-
}
|
|
570
|
-
if (error instanceof InsForgeError) {
|
|
571
|
-
return { data: null, error };
|
|
572
|
-
}
|
|
573
|
-
return {
|
|
574
|
-
data: null,
|
|
575
|
-
error: new InsForgeError(
|
|
576
|
-
"An unexpected error occurred while fetching user",
|
|
577
|
-
500,
|
|
578
|
-
"UNEXPECTED_ERROR"
|
|
579
|
-
)
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
543
|
/**
|
|
584
544
|
* Get any user's profile by ID
|
|
585
545
|
* Returns profile information from the users table
|
|
@@ -610,6 +570,9 @@ var Auth = class {
|
|
|
610
570
|
* Returns the stored JWT token and basic user info from local storage
|
|
611
571
|
*/
|
|
612
572
|
async getCurrentSession() {
|
|
573
|
+
if (isHostedAuthEnvironment()) {
|
|
574
|
+
return { data: { session: null }, error: null };
|
|
575
|
+
}
|
|
613
576
|
try {
|
|
614
577
|
const session = this.tokenManager.getSession();
|
|
615
578
|
if (session) {
|