@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
@@ -53,6 +53,7 @@ var import_react = require("@stackframe/stack-shared/dist/utils/react");
53
53
  var import_results = require("@stackframe/stack-shared/dist/utils/results");
54
54
  var import_stores = require("@stackframe/stack-shared/dist/utils/stores");
55
55
  var import_strings = require("@stackframe/stack-shared/dist/utils/strings");
56
+ var import_urls = require("@stackframe/stack-shared/dist/utils/urls");
56
57
  var import_uuids = require("@stackframe/stack-shared/dist/utils/uuids");
57
58
  var cookie = __toESM(require("cookie"));
58
59
  var NextNavigationUnscrambled = __toESM(require("next/navigation"));
@@ -61,23 +62,25 @@ var import_url = require("../utils/url");
61
62
  var import_auth = require("./auth");
62
63
  var import_cookie = require("./cookie");
63
64
  var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
64
- var clientVersion = "js @stackframe/stack@2.5.7";
65
+ var clientVersion = "js @stackframe/stack@2.5.9";
65
66
  function getUrls(partial) {
66
67
  const handler = partial.handler ?? "/handler";
68
+ const home = partial.home ?? "/";
69
+ const afterSignIn = partial.afterSignIn ?? home;
67
70
  return {
68
71
  handler,
69
72
  signIn: `${handler}/sign-in`,
70
- afterSignIn: "/",
73
+ afterSignIn: home,
71
74
  signUp: `${handler}/sign-up`,
72
- afterSignUp: "/",
75
+ afterSignUp: afterSignIn,
73
76
  signOut: `${handler}/sign-out`,
74
- afterSignOut: "/",
77
+ afterSignOut: home,
75
78
  emailVerification: `${handler}/email-verification`,
76
79
  passwordReset: `${handler}/password-reset`,
77
80
  forgotPassword: `${handler}/forgot-password`,
78
81
  oauthCallback: `${handler}/oauth-callback`,
79
82
  magicLinkCallback: `${handler}/magic-link-callback`,
80
- home: "/",
83
+ home,
81
84
  accountSettings: `${handler}/account-settings`,
82
85
  error: `${handler}/error`,
83
86
  ...(0, import_objects.filterUndefined)(partial)
@@ -85,7 +88,7 @@ function getUrls(partial) {
85
88
  }
86
89
  async function _redirectTo(url, options) {
87
90
  if (import_stack_sc.isReactServer) {
88
- NextNavigation.redirect(url, options?.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
91
+ NextNavigation.redirect(url.toString(), options?.replace ? NextNavigation.RedirectType.replace : NextNavigation.RedirectType.push);
89
92
  } else {
90
93
  if (options?.replace) {
91
94
  window.location.replace(url);
@@ -188,7 +191,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
188
191
  this._currentUserOAuthConnectionAccessTokensCache = createCacheBySession(
189
192
  async (session, [accountId, scope]) => {
190
193
  try {
191
- return await this._interface.getAccessToken(accountId, scope || "", session);
194
+ const result = await this._interface.createProviderAccessToken(accountId, scope || "", session);
195
+ return {
196
+ accessToken: result.access_token
197
+ };
192
198
  } catch (err) {
193
199
  if (!(err instanceof import_stack_shared.KnownErrors.OAuthConnectionDoesNotHaveRequiredScope || err instanceof import_stack_shared.KnownErrors.OAuthConnectionNotConnectedToUser)) {
194
200
  throw err;
@@ -300,12 +306,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
300
306
  }
301
307
  return this._uniqueIdentifier;
302
308
  }
303
- async _checkFeatureSupport(featureName, options) {
304
- return await this._interface.checkFeatureSupport({ ...options, featureName });
309
+ async _checkFeatureSupport(name, options) {
310
+ return await this._interface.checkFeatureSupport({ ...options, name });
305
311
  }
306
- _useCheckFeatureSupport(featureName, options) {
307
- (0, import_promises.runAsynchronously)(this._checkFeatureSupport(featureName, options));
308
- throw new import_errors.StackAssertionError(`${featureName} is not currently supported. Please reach out to Stack support for more information.`);
312
+ _useCheckFeatureSupport(name, options) {
313
+ (0, import_promises.runAsynchronously)(this._checkFeatureSupport(name, options));
314
+ throw new import_errors.StackAssertionError(`${name} is not currently supported. Please reach out to Stack support for more information.`);
309
315
  }
310
316
  get _refreshTokenCookieName() {
311
317
  return `stack-refresh-${this.projectId}`;
@@ -552,7 +558,6 @@ var _StackClientAppImpl = class __StackClientAppImpl {
552
558
  throw new import_errors.StackAssertionError("User not found");
553
559
  }
554
560
  return {
555
- projectId: crud.project_id,
556
561
  id: crud.id,
557
562
  displayName: crud.display_name,
558
563
  primaryEmail: crud.primary_email,
@@ -569,7 +574,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
569
574
  }
570
575
  };
571
576
  }
572
- _createCurrentUserExtra(crud, session) {
577
+ _createUserExtra(crud, session) {
573
578
  const app = this;
574
579
  async function getConnectedAccount(id, options) {
575
580
  const scopeString = options?.scopes?.join(" ");
@@ -639,7 +644,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
639
644
  return app._updateClientUser(update, session);
640
645
  },
641
646
  sendVerificationEmail() {
642
- return app._sendVerificationEmail(session);
647
+ if (!crud?.primary_email) {
648
+ throw new import_errors.StackAssertionError("User does not have a primary email");
649
+ }
650
+ return app._sendVerificationEmail(crud.primary_email, session);
643
651
  },
644
652
  updatePassword(options) {
645
653
  return app._updatePassword(options, session);
@@ -665,7 +673,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
665
673
  const currentUser = {
666
674
  ...this._createBaseUser(crud),
667
675
  ...this._createAuth(session),
668
- ...this._createCurrentUserExtra(crud, session),
676
+ ...this._createUserExtra(crud, session),
669
677
  ...this._isInternalProject() ? this._createInternalUserExtra(session) : {}
670
678
  };
671
679
  Object.freeze(currentUser);
@@ -686,57 +694,93 @@ var _StackClientAppImpl = class __StackClientAppImpl {
686
694
  get projectId() {
687
695
  return this._interface.projectId;
688
696
  }
697
+ async _isTrusted(url) {
698
+ return (0, import_urls.isRelative)(url);
699
+ }
689
700
  get urls() {
690
701
  return getUrls(this._urlOptions);
691
702
  }
692
- async _redirectTo(handlerName, options) {
693
- const url = this.urls[handlerName];
703
+ async _redirectIfTrusted(url, options) {
704
+ if (!await this._isTrusted(url)) {
705
+ throw new Error(`Redirect URL ${url} is not trusted; should be relative.`);
706
+ }
707
+ return await _redirectTo(url, options);
708
+ }
709
+ async _redirectToHandler(handlerName, options) {
710
+ let url = this.urls[handlerName];
694
711
  if (!url) {
695
712
  throw new Error(`No URL for handler name ${handlerName}`);
696
713
  }
697
- await _redirectTo(url, options);
714
+ if (handlerName === "afterSignIn" || handlerName === "afterSignUp") {
715
+ if (import_stack_sc.isReactServer || typeof window === "undefined") {
716
+ try {
717
+ await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
718
+ } catch (e) {
719
+ }
720
+ } else {
721
+ const queryParams = new URLSearchParams(window.location.search);
722
+ url = queryParams.get("after_auth_return_to") || url;
723
+ }
724
+ } else if (handlerName === "signIn" || handlerName === "signUp") {
725
+ if (import_stack_sc.isReactServer || typeof window === "undefined") {
726
+ try {
727
+ await this._checkFeatureSupport("rsc-handler-" + handlerName, {});
728
+ } catch (e) {
729
+ }
730
+ } else {
731
+ const currentUrl = new URL(window.location.href);
732
+ const nextUrl = new URL(url, currentUrl);
733
+ if (currentUrl.searchParams.has("after_auth_return_to")) {
734
+ nextUrl.searchParams.set("after_auth_return_to", currentUrl.searchParams.get("after_auth_return_to"));
735
+ } else if (currentUrl.protocol === nextUrl.protocol && currentUrl.host === nextUrl.host) {
736
+ nextUrl.searchParams.set("after_auth_return_to", (0, import_urls.getRelativePart)(currentUrl));
737
+ }
738
+ url = (0, import_urls.getRelativePart)(nextUrl);
739
+ }
740
+ }
741
+ await this._redirectIfTrusted(url, options);
698
742
  }
699
- async redirectToSignIn() {
700
- return await this._redirectTo("signIn");
743
+ async redirectToSignIn(options) {
744
+ return await this._redirectToHandler("signIn", options);
701
745
  }
702
- async redirectToSignUp() {
703
- return await this._redirectTo("signUp");
746
+ async redirectToSignUp(options) {
747
+ return await this._redirectToHandler("signUp", options);
704
748
  }
705
- async redirectToSignOut() {
706
- return await this._redirectTo("signOut");
749
+ async redirectToSignOut(options) {
750
+ return await this._redirectToHandler("signOut", options);
707
751
  }
708
- async redirectToEmailVerification() {
709
- return await this._redirectTo("emailVerification");
752
+ async redirectToEmailVerification(options) {
753
+ return await this._redirectToHandler("emailVerification", options);
710
754
  }
711
- async redirectToPasswordReset() {
712
- return await this._redirectTo("passwordReset");
755
+ async redirectToPasswordReset(options) {
756
+ return await this._redirectToHandler("passwordReset", options);
713
757
  }
714
- async redirectToForgotPassword() {
715
- return await this._redirectTo("forgotPassword");
758
+ async redirectToForgotPassword(options) {
759
+ return await this._redirectToHandler("forgotPassword", options);
716
760
  }
717
- async redirectToHome() {
718
- return await this._redirectTo("home");
761
+ async redirectToHome(options) {
762
+ return await this._redirectToHandler("home", options);
719
763
  }
720
- async redirectToOAuthCallback() {
721
- return await this._redirectTo("oauthCallback");
764
+ async redirectToOAuthCallback(options) {
765
+ return await this._redirectToHandler("oauthCallback", options);
722
766
  }
723
- async redirectToMagicLinkCallback() {
724
- return await this._redirectTo("magicLinkCallback");
767
+ async redirectToMagicLinkCallback(options) {
768
+ return await this._redirectToHandler("magicLinkCallback", options);
725
769
  }
726
- async redirectToAfterSignIn() {
727
- return await this._redirectTo("afterSignIn");
770
+ async redirectToAfterSignIn(options) {
771
+ return await this._redirectToHandler("afterSignIn", options);
728
772
  }
729
- async redirectToAfterSignUp() {
730
- return await this._redirectTo("afterSignUp");
773
+ async redirectToAfterSignUp(options) {
774
+ return await this._redirectToHandler("afterSignUp", options);
731
775
  }
732
- async redirectToAfterSignOut() {
733
- return await this._redirectTo("afterSignOut");
776
+ async redirectToAfterSignOut(options) {
777
+ return await this._redirectToHandler("afterSignOut", options);
734
778
  }
735
- async redirectToAccountSettings() {
736
- return await this._redirectTo("accountSettings");
779
+ async redirectToAccountSettings(options) {
780
+ return await this._redirectToHandler("accountSettings", options);
737
781
  }
738
- async redirectToError() {
739
- return await this._redirectTo("error");
782
+ async redirectToError(options) {
783
+ return await this._redirectToHandler("error", options);
740
784
  }
741
785
  async sendForgotPasswordEmail(email) {
742
786
  const redirectUrl = (0, import_url.constructRedirectUrl)(this.urls.passwordReset);
@@ -765,7 +809,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
765
809
  if (crud === null) {
766
810
  switch (options?.or) {
767
811
  case "redirect": {
768
- await this.redirectToSignIn();
812
+ await this.redirectToSignIn({ replace: true });
769
813
  break;
770
814
  }
771
815
  case "throw": {
@@ -786,7 +830,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
786
830
  if (crud === null) {
787
831
  switch (options?.or) {
788
832
  case "redirect": {
789
- setTimeout(() => router.replace(this.urls.signIn), 0);
833
+ (0, import_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
790
834
  (0, import_react.suspend)();
791
835
  throw new import_errors.StackAssertionError("suspend should never return");
792
836
  }
@@ -880,9 +924,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
880
924
  await this._interface.signOut(session);
881
925
  await this.redirectToAfterSignOut();
882
926
  }
883
- async _sendVerificationEmail(session) {
927
+ async _sendVerificationEmail(email, session) {
884
928
  const emailVerificationRedirectUrl = (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
885
- return await this._interface.sendVerificationEmail(emailVerificationRedirectUrl, session);
929
+ return await this._interface.sendVerificationEmail(email, emailVerificationRedirectUrl, session);
886
930
  }
887
931
  async _updatePassword(options, session) {
888
932
  return await this._interface.updatePassword(options, session);
@@ -1027,7 +1071,13 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1027
1071
  return await this._interface.listServerTeamMemberPermissions({ teamId, userId, recursive });
1028
1072
  });
1029
1073
  }
1074
+ async _updateServerUser(userId, update) {
1075
+ const result = await this._interface.updateServerUser(userId, userUpdateOptionsToCrud(update));
1076
+ await this._refreshUsers();
1077
+ return result;
1078
+ }
1030
1079
  _createBaseUser(crud) {
1080
+ const app = this;
1031
1081
  if (!crud) {
1032
1082
  throw new import_errors.StackAssertionError("User not found");
1033
1083
  }
@@ -1036,10 +1086,41 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1036
1086
  ..."server_metadata" in crud ? {
1037
1087
  // server user
1038
1088
  serverMetadata: crud.server_metadata
1039
- } : {}
1089
+ } : {},
1090
+ async setServerMetadata(metadata) {
1091
+ await app._updateServerUser(crud.id, { serverMetadata: metadata });
1092
+ },
1093
+ async setPrimaryEmail(email, options) {
1094
+ await app._updateServerUser(crud.id, { primaryEmail: email, primaryEmailVerified: options?.verified });
1095
+ },
1096
+ async grantPermission(scope, permissionId) {
1097
+ await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);
1098
+ for (const recursive of [true, false]) {
1099
+ await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
1100
+ }
1101
+ },
1102
+ async revokePermission(scope, permissionId) {
1103
+ await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);
1104
+ for (const recursive of [true, false]) {
1105
+ await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
1106
+ }
1107
+ },
1108
+ async delete() {
1109
+ const res = await app._interface.deleteServerServerUser(crud.id);
1110
+ await app._refreshUsers();
1111
+ return res;
1112
+ },
1113
+ async createSession(options) {
1114
+ const tokens = await app._interface.createServerUserSession(crud.id, options.expiresInMillis ?? 1e3 * 60 * 60 * 24 * 365);
1115
+ return {
1116
+ async getTokens() {
1117
+ return tokens;
1118
+ }
1119
+ };
1120
+ }
1040
1121
  };
1041
1122
  }
1042
- _createCurrentUserExtra(crud) {
1123
+ _createUserExtra(crud) {
1043
1124
  if (!crud) {
1044
1125
  throw new import_errors.StackAssertionError("User not found");
1045
1126
  }
@@ -1051,15 +1132,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1051
1132
  async setClientMetadata(metadata) {
1052
1133
  return await this.update({ clientMetadata: metadata });
1053
1134
  },
1054
- async setServerMetadata(metadata) {
1055
- return await this.update({ serverMetadata: metadata });
1056
- },
1057
1135
  async setSelectedTeam(team) {
1058
1136
  return await this.update({ selectedTeamId: team?.id ?? null });
1059
1137
  },
1060
- async setPrimaryEmail(email, options) {
1061
- return await this.update({ primaryEmail: email, primaryEmailVerified: options?.verified });
1062
- },
1063
1138
  getConnectedAccount: async () => {
1064
1139
  return await app._checkFeatureSupport("getConnectedAccount() on ServerUser", {});
1065
1140
  },
@@ -1106,26 +1181,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1106
1181
  async hasPermission(scope, permissionId) {
1107
1182
  return await this.getPermission(scope, permissionId) !== null;
1108
1183
  },
1109
- async grantPermission(scope, permissionId) {
1110
- await app._interface.grantServerTeamUserPermission(scope.id, crud.id, permissionId);
1111
- for (const recursive of [true, false]) {
1112
- await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
1113
- }
1114
- },
1115
- async revokePermission(scope, permissionId) {
1116
- await app._interface.revokeServerTeamUserPermission(scope.id, crud.id, permissionId);
1117
- for (const recursive of [true, false]) {
1118
- await app._serverTeamUserPermissionsCache.refresh([scope.id, crud.id, recursive]);
1119
- }
1120
- },
1121
- async delete() {
1122
- const res = await app._interface.deleteServerServerUser(crud.id);
1123
- await app._refreshUsers();
1124
- return res;
1125
- },
1126
1184
  async update(update) {
1127
- const res = await app._interface.updateServerUser(crud.id, serverUserUpdateOptionsToCrud(update));
1128
- await app._refreshUsers();
1185
+ await app._updateServerUser(crud.id, update);
1129
1186
  },
1130
1187
  async sendVerificationEmail() {
1131
1188
  return await app._checkFeatureSupport("sendVerificationEmail() on ServerUser", {});
@@ -1137,8 +1194,8 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1137
1194
  }
1138
1195
  _serverUserFromCrud(crud) {
1139
1196
  return {
1140
- ...this._createBaseUser(crud),
1141
- ...this._createCurrentUserExtra(crud)
1197
+ ...this._createUserExtra(crud),
1198
+ ...this._createBaseUser(crud)
1142
1199
  };
1143
1200
  }
1144
1201
  _currentUserFromCrud(crud, session) {
@@ -1196,7 +1253,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1196
1253
  if (crud === null) {
1197
1254
  switch (options?.or) {
1198
1255
  case "redirect": {
1199
- await this.redirectToSignIn();
1256
+ await this.redirectToSignIn({ replace: true });
1200
1257
  break;
1201
1258
  }
1202
1259
  case "throw": {
@@ -1225,7 +1282,7 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1225
1282
  if (crud === null) {
1226
1283
  switch (options?.or) {
1227
1284
  case "redirect": {
1228
- setTimeout(() => router.replace(this.urls.signIn), 0);
1285
+ (0, import_promises.runAsynchronously)(this.redirectToSignIn({ replace: true }));
1229
1286
  (0, import_react.suspend)();
1230
1287
  throw new import_errors.StackAssertionError("suspend should never return");
1231
1288
  }
@@ -1541,16 +1598,6 @@ function userUpdateOptionsToCrud(options) {
1541
1598
  selected_team_id: options.selectedTeamId
1542
1599
  };
1543
1600
  }
1544
- function serverUserUpdateOptionsToCrud(options) {
1545
- return {
1546
- display_name: options.displayName,
1547
- client_metadata: options.clientMetadata,
1548
- selected_team_id: options.selectedTeamId,
1549
- primary_email: options.primaryEmail,
1550
- primary_email_verified: options.primaryEmailVerified,
1551
- server_metadata: options.serverMetadata
1552
- };
1553
- }
1554
1601
  function adminProjectUpdateOptionsToCrud(options) {
1555
1602
  return {
1556
1603
  display_name: options.displayName,