@stackframe/stack 2.6.11 → 2.6.12

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.
@@ -67,6 +67,31 @@ type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string>
67
67
  uniqueIdentifier: string;
68
68
  };
69
69
  declare const stackAppInternalsSymbol: unique symbol;
70
+ type ContactChannel = {
71
+ id: string;
72
+ value: string;
73
+ type: 'email';
74
+ isPrimary: boolean;
75
+ isVerified: boolean;
76
+ usedForAuth: boolean;
77
+ sendVerificationEmail(): Promise<Result<undefined, KnownErrors["EmailAlreadyVerified"]>>;
78
+ update(data: ContactChannelUpdateOptions): Promise<void>;
79
+ delete(): Promise<void>;
80
+ };
81
+ type ContactChannelCreateOptions = {
82
+ value: string;
83
+ type: 'email';
84
+ usedForAuth: boolean;
85
+ };
86
+ type ContactChannelUpdateOptions = {
87
+ usedForAuth?: boolean;
88
+ value?: string;
89
+ isPrimary?: boolean;
90
+ };
91
+ type ServerContactChannel = ContactChannel;
92
+ type ServerContactChannelCreateOptions = ContactChannelCreateOptions & {
93
+ isVerified?: boolean;
94
+ };
70
95
  type Session = {
71
96
  getTokens(): Promise<{
72
97
  accessToken: string | null;
@@ -188,39 +213,47 @@ type BaseUser = {
188
213
  readonly signedUpAt: Date;
189
214
  readonly clientMetadata: any;
190
215
  readonly clientReadOnlyMetadata: any;
191
- /**
192
- * Whether the primary e-mail can be used for authentication.
193
- */
194
- readonly emailAuthEnabled: boolean;
195
216
  /**
196
217
  * Whether the user has a password set.
197
218
  */
198
219
  readonly hasPassword: boolean;
199
- /**
200
- * @deprecated
201
- */
202
- readonly oauthProviders: readonly {
203
- id: string;
204
- }[];
220
+ readonly otpAuthEnabled: boolean;
205
221
  readonly isMultiFactorRequired: boolean;
206
222
  /**
207
223
  * A shorthand method to update multiple fields of the user at once.
208
224
  */
209
225
  readonly selectedTeam: Team | null;
210
226
  toClientJson(): CurrentUserCrud["Client"]["Read"];
227
+ /**
228
+ * @deprecated, use contact channel's usedForAuth instead
229
+ */
230
+ readonly emailAuthEnabled: boolean;
231
+ /**
232
+ * @deprecated
233
+ */
234
+ readonly oauthProviders: readonly {
235
+ id: string;
236
+ }[];
211
237
  };
212
238
  type UserExtra = {
213
239
  setDisplayName(displayName: string): Promise<void>;
240
+ /** @deprecated Use contact channel's sendVerificationEmail instead */
214
241
  sendVerificationEmail(): Promise<KnownErrors["EmailAlreadyVerified"] | void>;
215
242
  setClientMetadata(metadata: any): Promise<void>;
216
243
  updatePassword(options: {
217
244
  oldPassword: string;
218
245
  newPassword: string;
219
246
  }): Promise<KnownErrors["PasswordConfirmationMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | void>;
247
+ setPassword(options: {
248
+ password: string;
249
+ }): Promise<KnownErrors["PasswordRequirementsNotMet"] | void>;
220
250
  /**
221
251
  * A shorthand method to update multiple fields of the user at once.
222
252
  */
223
253
  update(update: UserUpdateOptions): Promise<void>;
254
+ useContactChannels(): ContactChannel[];
255
+ listContactChannels(): Promise<ContactChannel[]>;
256
+ createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>;
224
257
  delete(): Promise<void>;
225
258
  getConnectedAccount(id: ProviderType, options: {
226
259
  or: 'redirect';
@@ -263,6 +296,7 @@ type UserUpdateOptions = {
263
296
  selectedTeamId?: string | null;
264
297
  totpMultiFactorSecret?: Uint8Array | null;
265
298
  profileImageUrl?: string | null;
299
+ otpAuthEnabled?: boolean;
266
300
  };
267
301
  type ServerBaseUser = {
268
302
  setPrimaryEmail(email: string, options?: {
@@ -272,14 +306,12 @@ type ServerBaseUser = {
272
306
  readonly serverMetadata: any;
273
307
  setServerMetadata(metadata: any): Promise<void>;
274
308
  setClientReadOnlyMetadata(metadata: any): Promise<void>;
275
- updatePassword(options: {
276
- oldPassword?: string;
277
- newPassword: string;
278
- }): Promise<KnownErrors["PasswordConfirmationMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | void>;
309
+ useContactChannels(): ServerContactChannel[];
310
+ listContactChannels(): Promise<ServerContactChannel[]>;
311
+ createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>;
279
312
  update(user: ServerUserUpdateOptions): Promise<void>;
280
313
  grantPermission(scope: Team, permissionId: string): Promise<void>;
281
314
  revokePermission(scope: Team, permissionId: string): Promise<void>;
282
- hasPermission(scope: Team, permissionId: string): Promise<boolean>;
283
315
  /**
284
316
  * Creates a new session object with a refresh token for this user. Can be used to impersonate them.
285
317
  */
@@ -307,8 +339,10 @@ type ServerUserUpdateOptions = {
307
339
  password?: string;
308
340
  } & UserUpdateOptions;
309
341
  type ServerUserCreateOptions = {
310
- primaryEmail: string;
311
- password: string;
342
+ primaryEmail?: string;
343
+ primaryEmailAuthEnabled?: boolean;
344
+ password?: string;
345
+ otpAuthEnabled?: boolean;
312
346
  displayName?: string;
313
347
  primaryEmailVerified?: boolean;
314
348
  };
@@ -67,6 +67,31 @@ type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string>
67
67
  uniqueIdentifier: string;
68
68
  };
69
69
  declare const stackAppInternalsSymbol: unique symbol;
70
+ type ContactChannel = {
71
+ id: string;
72
+ value: string;
73
+ type: 'email';
74
+ isPrimary: boolean;
75
+ isVerified: boolean;
76
+ usedForAuth: boolean;
77
+ sendVerificationEmail(): Promise<Result<undefined, KnownErrors["EmailAlreadyVerified"]>>;
78
+ update(data: ContactChannelUpdateOptions): Promise<void>;
79
+ delete(): Promise<void>;
80
+ };
81
+ type ContactChannelCreateOptions = {
82
+ value: string;
83
+ type: 'email';
84
+ usedForAuth: boolean;
85
+ };
86
+ type ContactChannelUpdateOptions = {
87
+ usedForAuth?: boolean;
88
+ value?: string;
89
+ isPrimary?: boolean;
90
+ };
91
+ type ServerContactChannel = ContactChannel;
92
+ type ServerContactChannelCreateOptions = ContactChannelCreateOptions & {
93
+ isVerified?: boolean;
94
+ };
70
95
  type Session = {
71
96
  getTokens(): Promise<{
72
97
  accessToken: string | null;
@@ -188,39 +213,47 @@ type BaseUser = {
188
213
  readonly signedUpAt: Date;
189
214
  readonly clientMetadata: any;
190
215
  readonly clientReadOnlyMetadata: any;
191
- /**
192
- * Whether the primary e-mail can be used for authentication.
193
- */
194
- readonly emailAuthEnabled: boolean;
195
216
  /**
196
217
  * Whether the user has a password set.
197
218
  */
198
219
  readonly hasPassword: boolean;
199
- /**
200
- * @deprecated
201
- */
202
- readonly oauthProviders: readonly {
203
- id: string;
204
- }[];
220
+ readonly otpAuthEnabled: boolean;
205
221
  readonly isMultiFactorRequired: boolean;
206
222
  /**
207
223
  * A shorthand method to update multiple fields of the user at once.
208
224
  */
209
225
  readonly selectedTeam: Team | null;
210
226
  toClientJson(): CurrentUserCrud["Client"]["Read"];
227
+ /**
228
+ * @deprecated, use contact channel's usedForAuth instead
229
+ */
230
+ readonly emailAuthEnabled: boolean;
231
+ /**
232
+ * @deprecated
233
+ */
234
+ readonly oauthProviders: readonly {
235
+ id: string;
236
+ }[];
211
237
  };
212
238
  type UserExtra = {
213
239
  setDisplayName(displayName: string): Promise<void>;
240
+ /** @deprecated Use contact channel's sendVerificationEmail instead */
214
241
  sendVerificationEmail(): Promise<KnownErrors["EmailAlreadyVerified"] | void>;
215
242
  setClientMetadata(metadata: any): Promise<void>;
216
243
  updatePassword(options: {
217
244
  oldPassword: string;
218
245
  newPassword: string;
219
246
  }): Promise<KnownErrors["PasswordConfirmationMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | void>;
247
+ setPassword(options: {
248
+ password: string;
249
+ }): Promise<KnownErrors["PasswordRequirementsNotMet"] | void>;
220
250
  /**
221
251
  * A shorthand method to update multiple fields of the user at once.
222
252
  */
223
253
  update(update: UserUpdateOptions): Promise<void>;
254
+ useContactChannels(): ContactChannel[];
255
+ listContactChannels(): Promise<ContactChannel[]>;
256
+ createContactChannel(data: ContactChannelCreateOptions): Promise<ContactChannel>;
224
257
  delete(): Promise<void>;
225
258
  getConnectedAccount(id: ProviderType, options: {
226
259
  or: 'redirect';
@@ -263,6 +296,7 @@ type UserUpdateOptions = {
263
296
  selectedTeamId?: string | null;
264
297
  totpMultiFactorSecret?: Uint8Array | null;
265
298
  profileImageUrl?: string | null;
299
+ otpAuthEnabled?: boolean;
266
300
  };
267
301
  type ServerBaseUser = {
268
302
  setPrimaryEmail(email: string, options?: {
@@ -272,14 +306,12 @@ type ServerBaseUser = {
272
306
  readonly serverMetadata: any;
273
307
  setServerMetadata(metadata: any): Promise<void>;
274
308
  setClientReadOnlyMetadata(metadata: any): Promise<void>;
275
- updatePassword(options: {
276
- oldPassword?: string;
277
- newPassword: string;
278
- }): Promise<KnownErrors["PasswordConfirmationMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | void>;
309
+ useContactChannels(): ServerContactChannel[];
310
+ listContactChannels(): Promise<ServerContactChannel[]>;
311
+ createContactChannel(data: ServerContactChannelCreateOptions): Promise<ServerContactChannel>;
279
312
  update(user: ServerUserUpdateOptions): Promise<void>;
280
313
  grantPermission(scope: Team, permissionId: string): Promise<void>;
281
314
  revokePermission(scope: Team, permissionId: string): Promise<void>;
282
- hasPermission(scope: Team, permissionId: string): Promise<boolean>;
283
315
  /**
284
316
  * Creates a new session object with a refresh token for this user. Can be used to impersonate them.
285
317
  */
@@ -307,8 +339,10 @@ type ServerUserUpdateOptions = {
307
339
  password?: string;
308
340
  } & UserUpdateOptions;
309
341
  type ServerUserCreateOptions = {
310
- primaryEmail: string;
311
- password: string;
342
+ primaryEmail?: string;
343
+ primaryEmailAuthEnabled?: boolean;
344
+ password?: string;
345
+ otpAuthEnabled?: boolean;
312
346
  displayName?: string;
313
347
  primaryEmailVerified?: boolean;
314
348
  };
@@ -63,7 +63,7 @@ var import_url = require("../utils/url");
63
63
  var import_auth = require("./auth");
64
64
  var import_cookie = require("./cookie");
65
65
  var NextNavigation = (0, import_compile_time.scrambleDuringCompileTime)(NextNavigationUnscrambled);
66
- var clientVersion = "js @stackframe/stack@2.6.11";
66
+ var clientVersion = "js @stackframe/stack@2.6.12";
67
67
  function getUrls(partial) {
68
68
  const handler = partial.handler ?? "/handler";
69
69
  const home = partial.home ?? "/";
@@ -101,10 +101,10 @@ async function _redirectTo(url, options) {
101
101
  }
102
102
  }
103
103
  function getDefaultProjectId() {
104
- return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || (0, import_errors.throwErr)(new Error("Welcome to Stack! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable."));
104
+ return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || (0, import_errors.throwErr)(new Error("Welcome to Stack Auth! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable."));
105
105
  }
106
106
  function getDefaultPublishableClientKey() {
107
- return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || (0, import_errors.throwErr)(new Error("Welcome to Stack! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable."));
107
+ return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || (0, import_errors.throwErr)(new Error("Welcome to Stack Auth! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable."));
108
108
  }
109
109
  function getDefaultSecretServerKey() {
110
110
  return process.env.STACK_SECRET_SERVER_KEY || (0, import_errors.throwErr)(new Error("No secret server key provided. Please copy your key from the Stack dashboard and put your it in the STACK_SECRET_SERVER_KEY environment variable."));
@@ -226,6 +226,11 @@ var _StackClientAppImpl = class __StackClientAppImpl {
226
226
  return await this._interface.getTeamMemberProfile({ teamId, userId: "me" }, session);
227
227
  }
228
228
  );
229
+ this._clientContactChannelsCache = createCacheBySession(
230
+ async (session) => {
231
+ return await this._interface.listClientContactChannels(session);
232
+ }
233
+ );
229
234
  this._memoryTokenStore = createEmptyTokenStore();
230
235
  this._requestTokenStores = /* @__PURE__ */ new WeakMap();
231
236
  this._storedCookieTokenStore = null;
@@ -589,6 +594,28 @@ var _StackClientAppImpl = class __StackClientAppImpl {
589
594
  }
590
595
  };
591
596
  }
597
+ _clientContactChannelFromCrud(crud) {
598
+ const app = this;
599
+ return {
600
+ id: crud.id,
601
+ value: crud.value,
602
+ type: crud.type,
603
+ isVerified: crud.is_verified,
604
+ isPrimary: crud.is_primary,
605
+ usedForAuth: crud.used_for_auth,
606
+ async sendVerificationEmail() {
607
+ return await app._interface.sendCurrentUserContactChannelVerificationEmail(crud.id, (0, import_url.constructRedirectUrl)(app.urls.emailVerification), app._getSession());
608
+ },
609
+ async update(data) {
610
+ await app._interface.updateClientContactChannel(crud.id, contactChannelUpdateOptionsToCrud(data), app._getSession());
611
+ await app._clientContactChannelsCache.refresh([app._getSession()]);
612
+ },
613
+ async delete() {
614
+ await app._interface.deleteClientContactChannel(crud.id, app._getSession());
615
+ await app._clientContactChannelsCache.refresh([app._getSession()]);
616
+ }
617
+ };
618
+ }
592
619
  _createAuth(session) {
593
620
  const app = this;
594
621
  return {
@@ -631,6 +658,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
631
658
  clientReadOnlyMetadata: crud.client_read_only_metadata,
632
659
  hasPassword: crud.has_password,
633
660
  emailAuthEnabled: crud.auth_with_email,
661
+ otpAuthEnabled: crud.otp_auth_enabled,
634
662
  oauthProviders: crud.oauth_providers,
635
663
  selectedTeam: crud.selected_team && this._clientTeamFromCrud(crud.selected_team),
636
664
  isMultiFactorRequired: crud.requires_totp_mfa,
@@ -739,7 +767,14 @@ var _StackClientAppImpl = class __StackClientAppImpl {
739
767
  return await app._sendVerificationEmail(crud.primary_email, session);
740
768
  },
741
769
  async updatePassword(options) {
742
- return await app._updatePassword(options, session);
770
+ const result = await app._interface.updatePassword(options, session);
771
+ await app._currentUserCache.refresh([session]);
772
+ return result;
773
+ },
774
+ async setPassword(options) {
775
+ const result = await app._interface.setPassword(options, session);
776
+ await app._currentUserCache.refresh([session]);
777
+ return result;
743
778
  },
744
779
  async getTeamProfile(team) {
745
780
  const result = await app._currentUserTeamProfileCache.getOrWait([session, team.id], "write-only");
@@ -752,6 +787,19 @@ var _StackClientAppImpl = class __StackClientAppImpl {
752
787
  async delete() {
753
788
  await app._interface.deleteCurrentUser(session);
754
789
  session.markInvalid();
790
+ },
791
+ async listContactChannels() {
792
+ const result = await app._clientContactChannelsCache.getOrWait([session], "write-only");
793
+ return result.map((crud2) => app._clientContactChannelFromCrud(crud2));
794
+ },
795
+ useContactChannels() {
796
+ const result = useAsyncCache(app._clientContactChannelsCache, [session], "user.useContactChannels()");
797
+ return result.map((crud2) => app._clientContactChannelFromCrud(crud2));
798
+ },
799
+ async createContactChannel(data) {
800
+ const crud2 = await app._interface.createClientContactChannel(contactChannelCreateOptionsToCrud("me", data), session);
801
+ await app._clientContactChannelsCache.refresh([session]);
802
+ return app._clientContactChannelFromCrud(crud2);
755
803
  }
756
804
  };
757
805
  }
@@ -934,7 +982,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
934
982
  }
935
983
  }
936
984
  async verifyEmail(code) {
937
- return await this._interface.verifyEmail(code);
985
+ const result = await this._interface.verifyEmail(code);
986
+ await this._currentUserCache.refresh([this._getSession()]);
987
+ await this._clientContactChannelsCache.refresh([this._getSession()]);
988
+ return result;
938
989
  }
939
990
  async getUser(options) {
940
991
  this._ensurePersistentTokenStore(options?.tokenStore);
@@ -1131,9 +1182,6 @@ var _StackClientAppImpl = class __StackClientAppImpl {
1131
1182
  const emailVerificationRedirectUrl = (0, import_url.constructRedirectUrl)(this.urls.emailVerification);
1132
1183
  return await this._interface.sendVerificationEmail(email, emailVerificationRedirectUrl, session);
1133
1184
  }
1134
- async _updatePassword(options, session) {
1135
- return await this._interface.updatePassword(options, session);
1136
- }
1137
1185
  async signOut() {
1138
1186
  const user = await this.getUser();
1139
1187
  if (user) {
@@ -1303,6 +1351,11 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1303
1351
  return await this._interface.getServerTeamMemberProfile({ teamId, userId });
1304
1352
  }
1305
1353
  );
1354
+ this._serverContactChannelsCache = createCache(
1355
+ async ([userId]) => {
1356
+ return await this._interface.listServerContactChannels(userId);
1357
+ }
1358
+ );
1306
1359
  }
1307
1360
  async _updateServerUser(userId, update) {
1308
1361
  const result = await this._interface.updateServerUser(userId, serverUserUpdateOptionsToCrud(update));
@@ -1320,6 +1373,21 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1320
1373
  }
1321
1374
  };
1322
1375
  }
1376
+ _serverContactChannelFromCrud(userId, crud) {
1377
+ const app = this;
1378
+ return {
1379
+ ...this._clientContactChannelFromCrud(crud),
1380
+ async sendVerificationEmail() {
1381
+ return await app._interface.sendServerContactChannelVerificationEmail(userId, crud.id, (0, import_url.constructRedirectUrl)(app.urls.emailVerification));
1382
+ },
1383
+ async update(data) {
1384
+ await app._interface.updateServerContactChannel(userId, crud.id, serverContactChannelUpdateOptionsToCrud(data));
1385
+ },
1386
+ async delete() {
1387
+ await app._interface.deleteServerContactChannel(userId, crud.id);
1388
+ }
1389
+ };
1390
+ }
1323
1391
  _serverUserFromCrud(crud) {
1324
1392
  const app = this;
1325
1393
  async function getConnectedAccount(id, options) {
@@ -1436,7 +1504,14 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1436
1504
  return await app._checkFeatureSupport("sendVerificationEmail() on ServerUser", {});
1437
1505
  },
1438
1506
  async updatePassword(options) {
1439
- return await this.update({ password: options.newPassword });
1507
+ const result = await this.update({ password: options.newPassword });
1508
+ await app._serverUserCache.refresh([crud.id]);
1509
+ return result;
1510
+ },
1511
+ async setPassword(options) {
1512
+ const result = await this.update(options);
1513
+ await app._serverUserCache.refresh([crud.id]);
1514
+ return result;
1440
1515
  },
1441
1516
  async getTeamProfile(team) {
1442
1517
  const result = await app._serverUserTeamProfileCache.getOrWait([team.id, crud.id], "write-only");
@@ -1445,6 +1520,19 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
1445
1520
  useTeamProfile(team) {
1446
1521
  const result = useAsyncCache(app._serverUserTeamProfileCache, [team.id, crud.id], "user.useTeamProfile()");
1447
1522
  return (0, import_react2.useMemo)(() => app._serverEditableTeamProfileFromCrud(result), [result]);
1523
+ },
1524
+ async listContactChannels() {
1525
+ const result = await app._serverContactChannelsCache.getOrWait([crud.id], "write-only");
1526
+ return result.map((data) => app._serverContactChannelFromCrud(crud.id, data));
1527
+ },
1528
+ useContactChannels() {
1529
+ const result = useAsyncCache(app._serverContactChannelsCache, [crud.id], "user.useContactChannels()");
1530
+ return (0, import_react2.useMemo)(() => result.map((data) => app._serverContactChannelFromCrud(crud.id, data)), [result]);
1531
+ },
1532
+ createContactChannel: async (data) => {
1533
+ const contactChannel = await app._interface.createServerContactChannel(serverContactChannelCreateOptionsToCrud(crud.id, data));
1534
+ await app._serverContactChannelsCache.refresh([crud.id]);
1535
+ return app._serverContactChannelFromCrud(crud.id, contactChannel);
1448
1536
  }
1449
1537
  };
1450
1538
  }
@@ -1893,13 +1981,45 @@ var _StackAdminAppImpl = class extends _StackServerAppImpl {
1893
1981
  await this._apiKeysCache.refresh([]);
1894
1982
  }
1895
1983
  };
1984
+ function contactChannelCreateOptionsToCrud(userId, options) {
1985
+ return {
1986
+ value: options.value,
1987
+ type: options.type,
1988
+ used_for_auth: options.usedForAuth,
1989
+ user_id: userId
1990
+ };
1991
+ }
1992
+ function contactChannelUpdateOptionsToCrud(options) {
1993
+ return {
1994
+ value: options.value,
1995
+ used_for_auth: options.usedForAuth,
1996
+ is_primary: options.isPrimary
1997
+ };
1998
+ }
1999
+ function serverContactChannelUpdateOptionsToCrud(options) {
2000
+ return {
2001
+ value: options.value,
2002
+ is_verified: options.isVerified,
2003
+ used_for_auth: options.usedForAuth
2004
+ };
2005
+ }
2006
+ function serverContactChannelCreateOptionsToCrud(userId, options) {
2007
+ return {
2008
+ type: options.type,
2009
+ value: options.value,
2010
+ is_verified: options.isVerified,
2011
+ user_id: userId,
2012
+ used_for_auth: options.usedForAuth
2013
+ };
2014
+ }
1896
2015
  function userUpdateOptionsToCrud(options) {
1897
2016
  return {
1898
2017
  display_name: options.displayName,
1899
2018
  client_metadata: options.clientMetadata,
1900
2019
  selected_team_id: options.selectedTeamId,
1901
2020
  totp_secret_base64: options.totpMultiFactorSecret != null ? (0, import_bytes.encodeBase64)(options.totpMultiFactorSecret) : options.totpMultiFactorSecret,
1902
- profile_image_url: options.profileImageUrl
2021
+ profile_image_url: options.profileImageUrl,
2022
+ otp_auth_enabled: options.otpAuthEnabled
1903
2023
  };
1904
2024
  }
1905
2025
  function serverUserUpdateOptionsToCrud(options) {
@@ -1921,7 +2041,8 @@ function serverUserCreateOptionsToCrud(options) {
1921
2041
  return {
1922
2042
  primary_email: options.primaryEmail,
1923
2043
  password: options.password,
1924
- primary_email_auth_enabled: true,
2044
+ otp_auth_enabled: options.otpAuthEnabled,
2045
+ primary_email_auth_enabled: options.primaryEmailAuthEnabled,
1925
2046
  display_name: options.displayName,
1926
2047
  primary_email_verified: options.primaryEmailVerified
1927
2048
  };