@stackframe/stack 2.5.7 → 2.5.9

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/credential-sign-in.d.mts +5 -0
  3. package/dist/components/credential-sign-in.d.ts +5 -0
  4. package/dist/components/{credential-sign-in-form.js → credential-sign-in.js} +8 -8
  5. package/dist/components/credential-sign-in.js.map +1 -0
  6. package/dist/components/credential-sign-up.d.mts +5 -0
  7. package/dist/components/credential-sign-up.d.ts +5 -0
  8. package/dist/components/{credential-sign-up-form.js → credential-sign-up.js} +8 -8
  9. package/dist/components/credential-sign-up.js.map +1 -0
  10. package/dist/components/elements/user-avatar.d.mts +1 -1
  11. package/dist/components/elements/user-avatar.d.ts +1 -1
  12. package/dist/components/magic-link-sign-in.d.mts +5 -0
  13. package/dist/components/magic-link-sign-in.d.ts +5 -0
  14. package/dist/components/{magic-link-sign-in-form.js → magic-link-sign-in.js} +8 -8
  15. package/dist/components/magic-link-sign-in.js.map +1 -0
  16. package/dist/components/message-cards/predefined-message-card.js +8 -8
  17. package/dist/components/message-cards/predefined-message-card.js.map +1 -1
  18. package/dist/components/selected-team-switcher.d.mts +1 -1
  19. package/dist/components/selected-team-switcher.d.ts +1 -1
  20. package/dist/components/user-button.js +3 -3
  21. package/dist/components/user-button.js.map +1 -1
  22. package/dist/components-page/account-settings.js +4 -4
  23. package/dist/components-page/account-settings.js.map +1 -1
  24. package/dist/components-page/auth-page.js +21 -8
  25. package/dist/components-page/auth-page.js.map +1 -1
  26. package/dist/components-page/stack-handler.d.mts +2 -2
  27. package/dist/components-page/stack-handler.d.ts +2 -2
  28. package/dist/components-page/stack-handler.js +8 -15
  29. package/dist/components-page/stack-handler.js.map +1 -1
  30. package/dist/esm/components/{credential-sign-in-form.js → credential-sign-in.js} +4 -4
  31. package/dist/esm/components/credential-sign-in.js.map +1 -0
  32. package/dist/esm/components/{credential-sign-up-form.js → credential-sign-up.js} +4 -4
  33. package/dist/esm/components/credential-sign-up.js.map +1 -0
  34. package/dist/esm/components/{magic-link-sign-in-form.js → magic-link-sign-in.js} +4 -4
  35. package/dist/esm/components/magic-link-sign-in.js.map +1 -0
  36. package/dist/esm/components/message-cards/predefined-message-card.js +8 -8
  37. package/dist/esm/components/message-cards/predefined-message-card.js.map +1 -1
  38. package/dist/esm/components/user-button.js +3 -3
  39. package/dist/esm/components/user-button.js.map +1 -1
  40. package/dist/esm/components-page/account-settings.js +4 -4
  41. package/dist/esm/components-page/account-settings.js.map +1 -1
  42. package/dist/esm/components-page/auth-page.js +21 -8
  43. package/dist/esm/components-page/auth-page.js.map +1 -1
  44. package/dist/esm/components-page/stack-handler.js +8 -15
  45. package/dist/esm/components-page/stack-handler.js.map +1 -1
  46. package/dist/esm/index.js +7 -9
  47. package/dist/esm/index.js.map +1 -1
  48. package/dist/esm/lib/auth.js +3 -3
  49. package/dist/esm/lib/auth.js.map +1 -1
  50. package/dist/esm/lib/cookie.js +8 -6
  51. package/dist/esm/lib/cookie.js.map +1 -1
  52. package/dist/esm/lib/stack-app.js +139 -92
  53. package/dist/esm/lib/stack-app.js.map +1 -1
  54. package/dist/esm/providers/stack-provider-client.js +1 -3
  55. package/dist/esm/providers/stack-provider-client.js.map +1 -1
  56. package/dist/esm/utils/url.js +9 -1
  57. package/dist/esm/utils/url.js.map +1 -1
  58. package/dist/index.d.mts +5 -5
  59. package/dist/index.d.ts +5 -5
  60. package/dist/index.js +6 -8
  61. package/dist/index.js.map +1 -1
  62. package/dist/lib/auth.js +3 -3
  63. package/dist/lib/auth.js.map +1 -1
  64. package/dist/lib/cookie.js +6 -6
  65. package/dist/lib/cookie.js.map +1 -1
  66. package/dist/lib/hooks.d.mts +1 -1
  67. package/dist/lib/hooks.d.ts +1 -1
  68. package/dist/lib/stack-app.d.mts +58 -24
  69. package/dist/lib/stack-app.d.ts +58 -24
  70. package/dist/lib/stack-app.js +139 -92
  71. package/dist/lib/stack-app.js.map +1 -1
  72. package/dist/providers/stack-provider-client.d.mts +1 -1
  73. package/dist/providers/stack-provider-client.d.ts +1 -1
  74. package/dist/providers/stack-provider-client.js +1 -3
  75. package/dist/providers/stack-provider-client.js.map +1 -1
  76. package/dist/providers/stack-provider.d.mts +1 -1
  77. package/dist/providers/stack-provider.d.ts +1 -1
  78. package/dist/utils/url.js +9 -1
  79. package/dist/utils/url.js.map +1 -1
  80. package/package.json +6 -4
  81. package/dist/components/credential-sign-in-form.d.mts +0 -5
  82. package/dist/components/credential-sign-in-form.d.ts +0 -5
  83. package/dist/components/credential-sign-in-form.js.map +0 -1
  84. package/dist/components/credential-sign-up-form.d.mts +0 -5
  85. package/dist/components/credential-sign-up-form.d.ts +0 -5
  86. package/dist/components/credential-sign-up-form.js.map +0 -1
  87. package/dist/components/magic-link-sign-in-form.d.mts +0 -5
  88. package/dist/components/magic-link-sign-in-form.d.ts +0 -5
  89. package/dist/components/magic-link-sign-in-form.js.map +0 -1
  90. package/dist/esm/components/credential-sign-in-form.js.map +0 -1
  91. package/dist/esm/components/credential-sign-up-form.js.map +0 -1
  92. package/dist/esm/components/magic-link-sign-in-form.js.map +0 -1
@@ -14,6 +14,7 @@ import { suspend, suspendIfSsr } from "@stackframe/stack-shared/dist/utils/react
14
14
  import { Result } from "@stackframe/stack-shared/dist/utils/results";
15
15
  import { Store } from "@stackframe/stack-shared/dist/utils/stores";
16
16
  import { mergeScopeStrings } from "@stackframe/stack-shared/dist/utils/strings";
17
+ import { getRelativePart, isRelative } from "@stackframe/stack-shared/dist/utils/urls";
17
18
  import { generateUuid } from "@stackframe/stack-shared/dist/utils/uuids";
18
19
  import * as cookie from "cookie";
19
20
  import * as NextNavigationUnscrambled from "next/navigation";
@@ -22,23 +23,25 @@ import { constructRedirectUrl } from "../utils/url";
22
23
  import { addNewOAuthProviderOrScope, callOAuthCallback, signInWithOAuth } from "./auth";
23
24
  import { deleteCookie, getCookie, setOrDeleteCookie } from "./cookie";
24
25
  var NextNavigation = scrambleDuringCompileTime(NextNavigationUnscrambled);
25
- var clientVersion = "js @stackframe/stack@2.5.7";
26
+ var clientVersion = "js @stackframe/stack@2.5.9";
26
27
  function getUrls(partial) {
27
28
  const handler = partial.handler ?? "/handler";
29
+ const home = partial.home ?? "/";
30
+ const afterSignIn = partial.afterSignIn ?? home;
28
31
  return {
29
32
  handler,
30
33
  signIn: `${handler}/sign-in`,
31
- afterSignIn: "/",
34
+ afterSignIn: home,
32
35
  signUp: `${handler}/sign-up`,
33
- afterSignUp: "/",
36
+ afterSignUp: afterSignIn,
34
37
  signOut: `${handler}/sign-out`,
35
- afterSignOut: "/",
38
+ afterSignOut: home,
36
39
  emailVerification: `${handler}/email-verification`,
37
40
  passwordReset: `${handler}/password-reset`,
38
41
  forgotPassword: `${handler}/forgot-password`,
39
42
  oauthCallback: `${handler}/oauth-callback`,
40
43
  magicLinkCallback: `${handler}/magic-link-callback`,
41
- home: "/",
44
+ home,
42
45
  accountSettings: `${handler}/account-settings`,
43
46
  error: `${handler}/error`,
44
47
  ...filterUndefined(partial)
@@ -46,7 +49,7 @@ function getUrls(partial) {
46
49
  }
47
50
  async function _redirectTo(url, options) {
48
51
  if (isReactServer) {
49
- NextNavigation.redirect(url, options?.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
52
+ NextNavigation.redirect(url.toString(), options?.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
50
53
  } else {
51
54
  if (options?.replace) {
52
55
  window.location.replace(url);
@@ -149,7 +152,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
149
152
  this._currentUserOAuthConnectionAccessTokensCache = createCacheBySession(
150
153
  async (session, [accountId, scope]) => {
151
154
  try {
152
- return await this._interface.getAccessToken(accountId, scope || "", session);
155
+ const result = await this._interface.createProviderAccessToken(accountId, scope || "", session);
156
+ return {
157
+ accessToken: result.access_token
158
+ };
153
159
  } catch (err) {
154
160
  if (!(err instanceof KnownErrors.OAuthConnectionDoesNotHaveRequiredScope || err instanceof KnownErrors.OAuthConnectionNotConnectedToUser)) {
155
161
  throw err;
@@ -261,12 +267,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
261
267
  }
262
268
  return this._uniqueIdentifier;
263
269
  }
264
- async _checkFeatureSupport(featureName, options) {
265
- return await this._interface.checkFeatureSupport({ ...options, featureName });
270
+ async _checkFeatureSupport(name, options) {
271
+ return await this._interface.checkFeatureSupport({ ...options, name });
266
272
  }
267
- _useCheckFeatureSupport(featureName, options) {
268
- runAsynchronously(this._checkFeatureSupport(featureName, options));
269
- throw new StackAssertionError(`${featureName} is not currently supported. Please reach out to Stack support for more information.`);
273
+ _useCheckFeatureSupport(name, options) {
274
+ runAsynchronously(this._checkFeatureSupport(name, options));
275
+ throw new StackAssertionError(`${name} is not currently supported. Please reach out to Stack support for more information.`);
270
276
  }
271
277
  get _refreshTokenCookieName() {
272
278
  return `stack-refresh-${this.projectId}`;
@@ -513,7 +519,6 @@ var _StackClientAppImpl = class __StackClientAppImpl {
513
519
  throw new StackAssertionError("User not found");
514
520
  }
515
521
  return {
516
- projectId: crud.project_id,
517
522
  id: crud.id,
518
523
  displayName: crud.display_name,
519
524
  primaryEmail: crud.primary_email,
@@ -530,7 +535,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
530
535
  }
531
536
  };
532
537
  }
533
- _createCurrentUserExtra(crud, session) {
538
+ _createUserExtra(crud, session) {
534
539
  const app = this;
535
540
  async function getConnectedAccount(id, options) {
536
541
  const scopeString = options?.scopes?.join(" ");
@@ -600,7 +605,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
600
605
  return app._updateClientUser(update, session);
601
606
  },
602
607
  sendVerificationEmail() {
603
- return app._sendVerificationEmail(session);
608
+ if (!crud?.primary_email) {
609
+ throw new StackAssertionError("User does not have a primary email");
610
+ }
611
+ return app._sendVerificationEmail(crud.primary_email, session);
604
612
  },
605
613
  updatePassword(options) {
606
614
  return app._updatePassword(options, session);
@@ -626,7 +634,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
626
634
  const currentUser = {
627
635
  ...this._createBaseUser(crud),
628
636
  ...this._createAuth(session),
629
- ...this._createCurrentUserExtra(crud, session),
637
+ ...this._createUserExtra(crud, session),
630
638
  ...this._isInternalProject() ? this._createInternalUserExtra(session) : {}
631
639
  };
632
640
  Object.freeze(currentUser);
@@ -647,57 +655,93 @@ var _StackClientAppImpl = class __StackClientAppImpl {
647
655
  get projectId() {
648
656
  return this._interface.projectId;
649
657
  }
658
+ async _isTrusted(url) {
659
+ return isRelative(url);
660
+ }
650
661
  get urls() {
651
662
  return getUrls(this._urlOptions);
652
663
  }
653
- async _redirectTo(handlerName, options) {
654
- const url = this.urls[handlerName];
664
+ async _redirectIfTrusted(url, options) {
665
+ if (!await this._isTrusted(url)) {
666
+ throw new Error(`Redirect URL ${url} is not trusted; should be relative.`);
667
+ }
668
+ return await _redirectTo(url, options);
669
+ }
670
+ async _redirectToHandler(handlerName, options) {
671
+ let url = this.urls[handlerName];
655
672
  if (!url) {
656
673
  throw new Error(`No URL for handler name ${handlerName}`);
657
674
  }
658
- await _redirectTo(url, options);
675
+ if (handlerName === "afterSignIn" || handlerName === "afterSignUp") {
676
+ if (isReactServer || typeof window === "undefined") {
677
+ try {
678
+ await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
679
+ } catch (e) {
680
+ }
681
+ } else {
682
+ const queryParams = new URLSearchParams(window.location.search);
683
+ url = queryParams.get("after_auth_return_to") || url;
684
+ }
685
+ } else if (handlerName === "signIn" || handlerName === "signUp") {
686
+ if (isReactServer || typeof window === "undefined") {
687
+ try {
688
+ await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
689
+ } catch (e) {
690
+ }
691
+ } else {
692
+ const currentUrl = new URL(window.location.href);
693
+ const nextUrl = new URL(url, currentUrl);
694
+ if (currentUrl.searchParams.has("after_auth_return_to")) {
695
+ nextUrl.searchParams.set("after_auth_return_to", currentUrl.searchParams.get("after_auth_return_to"));
696
+ } else if (currentUrl.protocol === nextUrl.protocol && currentUrl.host === nextUrl.host) {
697
+ nextUrl.searchParams.set("after_auth_return_to", getRelativePart(currentUrl));
698
+ }
699
+ url = getRelativePart(nextUrl);
700
+ }
701
+ }
702
+ await this._redirectIfTrusted(url, options);
659
703
  }
660
- async redirectToSignIn() {
661
- return await this._redirectTo("signIn");
704
+ async redirectToSignIn(options) {
705
+ return await this._redirectToHandler("signIn", options);
662
706
  }
663
- async redirectToSignUp() {
664
- return await this._redirectTo("signUp");
707
+ async redirectToSignUp(options) {
708
+ return await this._redirectToHandler("signUp", options);
665
709
  }
666
- async redirectToSignOut() {
667
- return await this._redirectTo("signOut");
710
+ async redirectToSignOut(options) {
711
+ return await this._redirectToHandler("signOut", options);
668
712
  }
669
- async redirectToEmailVerification() {
670
- return await this._redirectTo("emailVerification");
713
+ async redirectToEmailVerification(options) {
714
+ return await this._redirectToHandler("emailVerification", options);
671
715
  }
672
- async redirectToPasswordReset() {
673
- return await this._redirectTo("passwordReset");
716
+ async redirectToPasswordReset(options) {
717
+ return await this._redirectToHandler("passwordReset", options);
674
718
  }
675
- async redirectToForgotPassword() {
676
- return await this._redirectTo("forgotPassword");
719
+ async redirectToForgotPassword(options) {
720
+ return await this._redirectToHandler("forgotPassword", options);
677
721
  }
678
- async redirectToHome() {
679
- return await this._redirectTo("home");
722
+ async redirectToHome(options) {
723
+ return await this._redirectToHandler("home", options);
680
724
  }
681
- async redirectToOAuthCallback() {
682
- return await this._redirectTo("oauthCallback");
725
+ async redirectToOAuthCallback(options) {
726
+ return await this._redirectToHandler("oauthCallback", options);
683
727
  }
684
- async redirectToMagicLinkCallback() {
685
- return await this._redirectTo("magicLinkCallback");
728
+ async redirectToMagicLinkCallback(options) {
729
+ return await this._redirectToHandler("magicLinkCallback", options);
686
730
  }
687
- async redirectToAfterSignIn() {
688
- return await this._redirectTo("afterSignIn");
731
+ async redirectToAfterSignIn(options) {
732
+ return await this._redirectToHandler("afterSignIn", options);
689
733
  }
690
- async redirectToAfterSignUp() {
691
- return await this._redirectTo("afterSignUp");
734
+ async redirectToAfterSignUp(options) {
735
+ return await this._redirectToHandler("afterSignUp", options);
692
736
  }
693
- async redirectToAfterSignOut() {
694
- return await this._redirectTo("afterSignOut");
737
+ async redirectToAfterSignOut(options) {
738
+ return await this._redirectToHandler("afterSignOut", options);
695
739
  }
696
- async redirectToAccountSettings() {
697
- return await this._redirectTo("accountSettings");
740
+ async redirectToAccountSettings(options) {
741
+ return await this._redirectToHandler("accountSettings", options);
698
742
  }
699
- async redirectToError() {
700
- return await this._redirectTo("error");
743
+ async redirectToError(options) {
744
+ return await this._redirectToHandler("error", options);
701
745
  }
702
746
  async sendForgotPasswordEmail(email) {
703
747
  const redirectUrl = constructRedirectUrl(this.urls.passwordReset);
@@ -726,7 +770,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
726
770
  if (crud === null) {
727
771
  switch (options?.or) {
728
772
  case "redirect": {
729
- await this.redirectToSignIn();
773
+ await this.redirectToSignIn({ replace: true });
730
774
  break;
731
775
  }
732
776
  case "throw": {
@@ -747,7 +791,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
747
791
  if (crud === null) {
748
792
  switch (options?.or) {
749
793
  case "redirect": {
750
- setTimeout(() => router.replace(this.urls.signIn), 0);
794
+ runAsynchronously(this.redirectToSignIn({ replace: true }));
751
795
  suspend();
752
796
  throw new StackAssertionError("suspend should never return");
753
797
  }
@@ -841,9 +885,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
841
885
  await this._interface.signOut(session);
842
886
  await this.redirectToAfterSignOut();
843
887
  }
844
- async _sendVerificationEmail(session) {
888
+ async _sendVerificationEmail(email, session) {
845
889
  const emailVerificationRedirectUrl = constructRedirectUrl(this.urls.emailVerification);
846
- return await this._interface.sendVerificationEmail(emailVerificationRedirectUrl, session);
890
+ return await this._interface.sendVerificationEmail(email, emailVerificationRedirectUrl, session);
847
891
  }
848
892
  async _updatePassword(options, session) {
849
893
  return await this._interface.updatePassword(options, session);
@@ -988,7 +1032,13 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
988
1032
  return await this._interface.listServerTeamMemberPermissions({ teamId, userId, recursive });
989
1033
  });
990
1034
  }
1035
+ async _updateServerUser(userId, update) {
1036
+ const result = await this._interface.updateServerUser(userId, userUpdateOptionsToCrud(update));
1037
+ await this._refreshUsers();
1038
+ return result;
1039
+ }
991
1040
  _createBaseUser(crud) {
1041
+ const app = this;
992
1042
  if (!crud) {
993
1043
  throw new StackAssertionError("User not found");
994
1044
  }
@@ -997,10 +1047,41 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
997
1047
  ..."server_metadata" in crud ? {
998
1048
  // server user
999
1049
  serverMetadata: crud.server_metadata
1000
- } : {}
1050
+ } : {},
1051
+ async setServerMetadata(metadata) {
1052
+ await app._updateServerUser(crud.id, { serverMetadata: metadata });
1053
+ },
1054
+ async setPrimaryEmail(email, options) {
1055
+ await app._updateServerUser(crud.id, { primaryEmail: email, primaryEmailVerified: options?.verified });
1056
+ },
1057
+ async grantPermission(scope, permissionId) {
1058
+ await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);
1059
+ for (const recursive of [true, false]) {
1060
+ await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
1061
+ }
1062
+ },
1063
+ async revokePermission(scope, permissionId) {
1064
+ await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);
1065
+ for (const recursive of [true, false]) {
1066
+ await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
1067
+ }
1068
+ },
1069
+ async delete() {
1070
+ const res = await app._interface.deleteServerServerUser(crud.id);
1071
+ await app._refreshUsers();
1072
+ return res;
1073
+ },
1074
+ async createSession(options) {
1075
+ const tokens = await app._interface.createServerUserSession(crud.id, options.expiresInMillis ?? 1e3 * 60 * 60 * 24 * 365);
1076
+ return {
1077
+ async getTokens() {
1078
+ return tokens;
1079
+ }
1080
+ };
1081
+ }
1001
1082
  };
1002
1083
  }
1003
- _createCurrentUserExtra(crud) {
1084
+ _createUserExtra(crud) {
1004
1085
  if (!crud) {
1005
1086
  throw new StackAssertionError("User not found");
1006
1087
  }
@@ -1012,15 +1093,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1012
1093
  async setClientMetadata(metadata) {
1013
1094
  return await this.update({ clientMetadata: metadata });
1014
1095
  },
1015
- async setServerMetadata(metadata) {
1016
- return await this.update({ serverMetadata: metadata });
1017
- },
1018
1096
  async setSelectedTeam(team) {
1019
1097
  return await this.update({ selectedTeamId: team?.id ?? null });
1020
1098
  },
1021
- async setPrimaryEmail(email, options) {
1022
- return await this.update({ primaryEmail: email, primaryEmailVerified: options?.verified });
1023
- },
1024
1099
  getConnectedAccount: async () => {
1025
1100
  return await app._checkFeatureSupport("getConnectedAccount() on ServerUser", {});
1026
1101
  },
@@ -1067,26 +1142,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1067
1142
  async hasPermission(scope, permissionId) {
1068
1143
  return await this.getPermission(scope, permissionId) !== null;
1069
1144
  },
1070
- async grantPermission(scope, permissionId) {
1071
- await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);
1072
- for (const recursive of [true, false]) {
1073
- await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
1074
- }
1075
- },
1076
- async revokePermission(scope, permissionId) {
1077
- await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);
1078
- for (const recursive of [true, false]) {
1079
- await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
1080
- }
1081
- },
1082
- async delete() {
1083
- const res = await app._interface.deleteServerServerUser(crud.id);
1084
- await app._refreshUsers();
1085
- return res;
1086
- },
1087
1145
  async update(update) {
1088
- const res = await app._interface.updateServerUser(crud.id, serverUserUpdateOptionsToCrud(update));
1089
- await app._refreshUsers();
1146
+ await app._updateServerUser(crud.id, update);
1090
1147
  },
1091
1148
  async sendVerificationEmail() {
1092
1149
  return await app._checkFeatureSupport("sendVerificationEmail() on ServerUser", {});
@@ -1098,8 +1155,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1098
1155
  }
1099
1156
  _serverUserFromCrud(crud) {
1100
1157
  return {
1101
- ...this._createBaseUser(crud),
1102
- ...this._createCurrentUserExtra(crud)
1158
+ ...this._createUserExtra(crud),
1159
+ ...this._createBaseUser(crud)
1103
1160
  };
1104
1161
  }
1105
1162
  _currentUserFromCrud(crud, session) {
@@ -1157,7 +1214,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1157
1214
  if (crud === null) {
1158
1215
  switch (options?.or) {
1159
1216
  case "redirect": {
1160
- await this.redirectToSignIn();
1217
+ await this.redirectToSignIn({ replace: true });
1161
1218
  break;
1162
1219
  }
1163
1220
  case "throw": {
@@ -1186,7 +1243,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1186
1243
  if (crud === null) {
1187
1244
  switch (options?.or) {
1188
1245
  case "redirect": {
1189
- setTimeout(() => router.replace(this.urls.signIn), 0);
1246
+ runAsynchronously(this.redirectToSignIn({ replace: true }));
1190
1247
  suspend();
1191
1248
  throw new StackAssertionError("suspend should never return");
1192
1249
  }
@@ -1502,16 +1559,6 @@ function userUpdateOptionsToCrud(options) {
1502
1559
  selected_team_id: options.selectedTeamId
1503
1560
  };
1504
1561
  }
1505
- function serverUserUpdateOptionsToCrud(options) {
1506
- return {
1507
- display_name: options.displayName,
1508
- client_metadata: options.clientMetadata,
1509
- selected_team_id: options.selectedTeamId,
1510
- primary_email: options.primaryEmail,
1511
- primary_email_verified: options.primaryEmailVerified,
1512
- server_metadata: options.serverMetadata
1513
- };
1514
- }
1515
1562
  function adminProjectUpdateOptionsToCrud(options) {
1516
1563
  return {
1517
1564
  display_name: options.displayName,