@insforge/sdk 1.0.7 → 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 CHANGED
@@ -227,16 +227,6 @@ declare class Auth {
227
227
  data: GetPublicAuthConfigResponse | null;
228
228
  error: InsForgeError | null;
229
229
  }>;
230
- /**
231
- * Get the current user with full profile information
232
- * Returns both auth info (id, email, role) and profile data (dynamic fields from users table)
233
- */
234
- getCurrentUser(): Promise<{
235
- data: {
236
- user: UserSchema;
237
- } | null;
238
- error: any | null;
239
- }>;
240
230
  /**
241
231
  * Get any user's profile by ID
242
232
  * Returns profile information from the users table
package/dist/index.d.ts CHANGED
@@ -227,16 +227,6 @@ declare class Auth {
227
227
  data: GetPublicAuthConfigResponse | null;
228
228
  error: InsForgeError | null;
229
229
  }>;
230
- /**
231
- * Get the current user with full profile information
232
- * Returns both auth info (id, email, role) and profile data (dynamic fields from users table)
233
- */
234
- getCurrentUser(): Promise<{
235
- data: {
236
- user: UserSchema;
237
- } | null;
238
- error: any | null;
239
- }>;
240
230
  /**
241
231
  * Get any user's profile by ID
242
232
  * Returns profile information from the users table
package/dist/index.js CHANGED
@@ -418,17 +418,18 @@ var Auth = class {
418
418
  */
419
419
  async signUp(request) {
420
420
  try {
421
- const response = await this.http.post("/api/auth/users", request);
421
+ const response = await this.http.post("/api/auth/users", request, { credentials: "include" });
422
422
  if (response.accessToken && response.user && !isHostedAuthEnvironment()) {
423
423
  const session = {
424
424
  accessToken: response.accessToken,
425
425
  user: response.user
426
426
  };
427
- this.tokenManager.saveSession(session);
428
- this.http.setAuthToken(response.accessToken);
429
427
  if (response.csrfToken) {
428
+ this.tokenManager.setMemoryMode();
430
429
  setCsrfToken(response.csrfToken);
431
430
  }
431
+ this.tokenManager.saveSession(session);
432
+ this.http.setAuthToken(response.accessToken);
432
433
  }
433
434
  return {
434
435
  data: response,
@@ -453,17 +454,18 @@ var Auth = class {
453
454
  */
454
455
  async signInWithPassword(request) {
455
456
  try {
456
- const response = await this.http.post("/api/auth/sessions", request);
457
+ const response = await this.http.post("/api/auth/sessions", request, { credentials: "include" });
457
458
  if (!isHostedAuthEnvironment()) {
458
459
  const session = {
459
460
  accessToken: response.accessToken,
460
461
  user: response.user
461
462
  };
462
- this.tokenManager.saveSession(session);
463
- this.http.setAuthToken(response.accessToken);
464
463
  if (response.csrfToken) {
464
+ this.tokenManager.setMemoryMode();
465
465
  setCsrfToken(response.csrfToken);
466
466
  }
467
+ this.tokenManager.saveSession(session);
468
+ this.http.setAuthToken(response.accessToken);
467
469
  }
468
470
  return {
469
471
  data: response,
@@ -577,46 +579,6 @@ var Auth = class {
577
579
  };
578
580
  }
579
581
  }
580
- /**
581
- * Get the current user with full profile information
582
- * Returns both auth info (id, email, role) and profile data (dynamic fields from users table)
583
- */
584
- async getCurrentUser() {
585
- try {
586
- const user = this.tokenManager.getUser();
587
- if (user) {
588
- return { data: { user }, error: null };
589
- }
590
- const accessToken = this.tokenManager.getAccessToken();
591
- if (!accessToken) {
592
- return { data: null, error: null };
593
- }
594
- this.http.setAuthToken(accessToken);
595
- const authResponse = await this.http.get("/api/auth/sessions/current");
596
- return {
597
- data: {
598
- user: authResponse.user
599
- },
600
- error: null
601
- };
602
- } catch (error) {
603
- if (error instanceof InsForgeError && error.statusCode === 401) {
604
- await this.signOut();
605
- return { data: null, error: null };
606
- }
607
- if (error instanceof InsForgeError) {
608
- return { data: null, error };
609
- }
610
- return {
611
- data: null,
612
- error: new InsForgeError(
613
- "An unexpected error occurred while fetching user",
614
- 500,
615
- "UNEXPECTED_ERROR"
616
- )
617
- };
618
- }
619
- }
620
582
  /**
621
583
  * Get any user's profile by ID
622
584
  * Returns profile information from the users table
@@ -647,6 +609,9 @@ var Auth = class {
647
609
  * Returns the stored JWT token and basic user info from local storage
648
610
  */
649
611
  async getCurrentSession() {
612
+ if (isHostedAuthEnvironment()) {
613
+ return { data: { session: null }, error: null };
614
+ }
650
615
  try {
651
616
  const session = this.tokenManager.getSession();
652
617
  if (session) {
@@ -894,18 +859,20 @@ var Auth = class {
894
859
  try {
895
860
  const response = await this.http.post(
896
861
  "/api/auth/email/verify",
897
- request
862
+ request,
863
+ { credentials: "include" }
898
864
  );
899
865
  if (!isHostedAuthEnvironment()) {
900
866
  const session = {
901
867
  accessToken: response.accessToken,
902
868
  user: response.user
903
869
  };
904
- this.tokenManager.saveSession(session);
905
- this.http.setAuthToken(response.accessToken);
906
870
  if (response.csrfToken) {
871
+ this.tokenManager.setMemoryMode();
907
872
  setCsrfToken(response.csrfToken);
908
873
  }
874
+ this.tokenManager.saveSession(session);
875
+ this.http.setAuthToken(response.accessToken);
909
876
  }
910
877
  return {
911
878
  data: response,