@stackframe/stack-shared 2.5.16 → 2.5.18

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.
@@ -8,6 +8,7 @@ export declare const usersCrudServerUpdateSchema: import("yup").ObjectSchema<{
8
8
  primary_email_verified: boolean | undefined;
9
9
  primary_email_auth_enabled: boolean | undefined;
10
10
  password: string | null | undefined;
11
+ totp_secret_base64: string | null | undefined;
11
12
  selected_team_id: string | null | undefined;
12
13
  }, import("yup").AnyObject, {
13
14
  display_name: undefined;
@@ -18,6 +19,7 @@ export declare const usersCrudServerUpdateSchema: import("yup").ObjectSchema<{
18
19
  primary_email_verified: undefined;
19
20
  primary_email_auth_enabled: undefined;
20
21
  password: undefined;
22
+ totp_secret_base64: undefined;
21
23
  selected_team_id: undefined;
22
24
  }, "">;
23
25
  export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
@@ -36,11 +38,35 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
36
38
  signed_up_at_millis: number;
37
39
  has_password: NonNullable<boolean | undefined>;
38
40
  auth_with_email: NonNullable<boolean | undefined>;
41
+ requires_totp_mfa: NonNullable<boolean | undefined>;
39
42
  oauth_providers: {
40
43
  email?: string | null | undefined;
41
44
  id: string;
42
45
  account_id: string;
43
46
  }[];
47
+ auth_methods: ({
48
+ type: "password";
49
+ identifier: string;
50
+ } | {
51
+ type: "otp";
52
+ contact_channel: {
53
+ type: "email";
54
+ email: string;
55
+ };
56
+ } | {
57
+ type: "oauth";
58
+ provider: {
59
+ type: string;
60
+ provider_user_id: string;
61
+ };
62
+ })[];
63
+ connected_accounts: {
64
+ type: "oauth";
65
+ provider: {
66
+ type: string;
67
+ provider_user_id: string;
68
+ };
69
+ }[];
44
70
  client_metadata: {} | null;
45
71
  server_metadata: {} | null;
46
72
  }, import("yup").AnyObject, {
@@ -59,7 +85,10 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
59
85
  signed_up_at_millis: undefined;
60
86
  has_password: undefined;
61
87
  auth_with_email: undefined;
88
+ requires_totp_mfa: undefined;
62
89
  oauth_providers: undefined;
90
+ auth_methods: undefined;
91
+ connected_accounts: undefined;
63
92
  client_metadata: undefined;
64
93
  server_metadata: undefined;
65
94
  }, "">;
@@ -72,6 +101,7 @@ export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
72
101
  primary_email_verified: boolean | undefined;
73
102
  primary_email_auth_enabled: boolean | undefined;
74
103
  password: string | null | undefined;
104
+ totp_secret_base64: string | null | undefined;
75
105
  selected_team_id: string | null | undefined;
76
106
  } & {
77
107
  oauth_providers: {
@@ -88,6 +118,7 @@ export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
88
118
  primary_email_verified: undefined;
89
119
  primary_email_auth_enabled: undefined;
90
120
  password: undefined;
121
+ totp_secret_base64: undefined;
91
122
  selected_team_id: undefined;
92
123
  oauth_providers: undefined;
93
124
  }, "">;
@@ -109,11 +140,35 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
109
140
  signed_up_at_millis: number;
110
141
  has_password: NonNullable<boolean | undefined>;
111
142
  auth_with_email: NonNullable<boolean | undefined>;
143
+ requires_totp_mfa: NonNullable<boolean | undefined>;
112
144
  oauth_providers: {
113
145
  email?: string | null | undefined;
114
146
  id: string;
115
147
  account_id: string;
116
148
  }[];
149
+ auth_methods: ({
150
+ type: "password";
151
+ identifier: string;
152
+ } | {
153
+ type: "otp";
154
+ contact_channel: {
155
+ type: "email";
156
+ email: string;
157
+ };
158
+ } | {
159
+ type: "oauth";
160
+ provider: {
161
+ type: string;
162
+ provider_user_id: string;
163
+ };
164
+ })[];
165
+ connected_accounts: {
166
+ type: "oauth";
167
+ provider: {
168
+ type: string;
169
+ provider_user_id: string;
170
+ };
171
+ }[];
117
172
  client_metadata: {} | null;
118
173
  server_metadata: {} | null;
119
174
  }, import("yup").AnyObject, {
@@ -132,7 +187,10 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
132
187
  signed_up_at_millis: undefined;
133
188
  has_password: undefined;
134
189
  auth_with_email: undefined;
190
+ requires_totp_mfa: undefined;
135
191
  oauth_providers: undefined;
192
+ auth_methods: undefined;
193
+ connected_accounts: undefined;
136
194
  client_metadata: undefined;
137
195
  server_metadata: undefined;
138
196
  }, "">;
@@ -145,6 +203,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
145
203
  primary_email_verified: boolean | undefined;
146
204
  primary_email_auth_enabled: boolean | undefined;
147
205
  password: string | null | undefined;
206
+ totp_secret_base64: string | null | undefined;
148
207
  selected_team_id: string | null | undefined;
149
208
  }, import("yup").AnyObject, {
150
209
  display_name: undefined;
@@ -155,6 +214,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
155
214
  primary_email_verified: undefined;
156
215
  primary_email_auth_enabled: undefined;
157
216
  password: undefined;
217
+ totp_secret_base64: undefined;
158
218
  selected_team_id: undefined;
159
219
  }, "">;
160
220
  serverCreateSchema: import("yup").ObjectSchema<{
@@ -166,6 +226,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
166
226
  primary_email_verified: boolean | undefined;
167
227
  primary_email_auth_enabled: boolean | undefined;
168
228
  password: string | null | undefined;
229
+ totp_secret_base64: string | null | undefined;
169
230
  selected_team_id: string | null | undefined;
170
231
  } & {
171
232
  oauth_providers: {
@@ -182,6 +243,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
182
243
  primary_email_verified: undefined;
183
244
  primary_email_auth_enabled: undefined;
184
245
  password: undefined;
246
+ totp_secret_base64: undefined;
185
247
  selected_team_id: undefined;
186
248
  oauth_providers: undefined;
187
249
  }, "">;
@@ -233,11 +295,35 @@ export declare const userCreatedWebhookEvent: {
233
295
  signed_up_at_millis: number;
234
296
  has_password: NonNullable<boolean | undefined>;
235
297
  auth_with_email: NonNullable<boolean | undefined>;
298
+ requires_totp_mfa: NonNullable<boolean | undefined>;
236
299
  oauth_providers: {
237
300
  email?: string | null | undefined;
238
301
  id: string;
239
302
  account_id: string;
240
303
  }[];
304
+ auth_methods: ({
305
+ type: "password";
306
+ identifier: string;
307
+ } | {
308
+ type: "otp";
309
+ contact_channel: {
310
+ type: "email";
311
+ email: string;
312
+ };
313
+ } | {
314
+ type: "oauth";
315
+ provider: {
316
+ type: string;
317
+ provider_user_id: string;
318
+ };
319
+ })[];
320
+ connected_accounts: {
321
+ type: "oauth";
322
+ provider: {
323
+ type: string;
324
+ provider_user_id: string;
325
+ };
326
+ }[];
241
327
  client_metadata: {} | null;
242
328
  server_metadata: {} | null;
243
329
  }, import("yup").AnyObject, {
@@ -256,7 +342,10 @@ export declare const userCreatedWebhookEvent: {
256
342
  signed_up_at_millis: undefined;
257
343
  has_password: undefined;
258
344
  auth_with_email: undefined;
345
+ requires_totp_mfa: undefined;
259
346
  oauth_providers: undefined;
347
+ auth_methods: undefined;
348
+ connected_accounts: undefined;
260
349
  client_metadata: undefined;
261
350
  server_metadata: undefined;
262
351
  }, "">;
@@ -284,11 +373,35 @@ export declare const userUpdatedWebhookEvent: {
284
373
  signed_up_at_millis: number;
285
374
  has_password: NonNullable<boolean | undefined>;
286
375
  auth_with_email: NonNullable<boolean | undefined>;
376
+ requires_totp_mfa: NonNullable<boolean | undefined>;
287
377
  oauth_providers: {
288
378
  email?: string | null | undefined;
289
379
  id: string;
290
380
  account_id: string;
291
381
  }[];
382
+ auth_methods: ({
383
+ type: "password";
384
+ identifier: string;
385
+ } | {
386
+ type: "otp";
387
+ contact_channel: {
388
+ type: "email";
389
+ email: string;
390
+ };
391
+ } | {
392
+ type: "oauth";
393
+ provider: {
394
+ type: string;
395
+ provider_user_id: string;
396
+ };
397
+ })[];
398
+ connected_accounts: {
399
+ type: "oauth";
400
+ provider: {
401
+ type: string;
402
+ provider_user_id: string;
403
+ };
404
+ }[];
292
405
  client_metadata: {} | null;
293
406
  server_metadata: {} | null;
294
407
  }, import("yup").AnyObject, {
@@ -307,7 +420,10 @@ export declare const userUpdatedWebhookEvent: {
307
420
  signed_up_at_millis: undefined;
308
421
  has_password: undefined;
309
422
  auth_with_email: undefined;
423
+ requires_totp_mfa: undefined;
310
424
  oauth_providers: undefined;
425
+ auth_methods: undefined;
426
+ connected_accounts: undefined;
311
427
  client_metadata: undefined;
312
428
  server_metadata: undefined;
313
429
  }, "">;
@@ -10,6 +10,7 @@ export const usersCrudServerUpdateSchema = fieldSchema.yupObject({
10
10
  primary_email_verified: fieldSchema.primaryEmailVerifiedSchema.optional(),
11
11
  primary_email_auth_enabled: fieldSchema.yupBoolean().optional().meta({ openapiField: { description: "Whether the primary email can be used to sign into this user's account", exampleValue: true } }),
12
12
  password: fieldSchema.yupString().nullable().meta({ openapiField: { description: 'A new password for the user, overwriting the old one (if it exists).', exampleValue: 'password' } }),
13
+ totp_secret_base64: fieldSchema.base64Schema.nullable().meta({ openapiField: { description: 'A TOTP secret for the user, overwriting the old one (if it exists). Set to null to disable 2FA.', exampleValue: 'dG90cC1zZWNyZXQ=' } }),
13
14
  selected_team_id: fieldSchema.selectedTeamIdSchema.nullable().optional(),
14
15
  }).required();
15
16
  export const usersCrudServerReadSchema = fieldSchema.yupObject({
@@ -22,12 +23,39 @@ export const usersCrudServerReadSchema = fieldSchema.yupObject({
22
23
  profile_image_url: fieldSchema.profileImageUrlSchema.nullable().defined(),
23
24
  signed_up_at_millis: fieldSchema.signedUpAtMillisSchema.required(),
24
25
  has_password: fieldSchema.yupBoolean().required().meta({ openapiField: { description: 'Whether the user has a password associated with their account', exampleValue: true } }),
25
- auth_with_email: fieldSchema.yupBoolean().required().meta({ openapiField: { description: 'Whether the user can authenticate with their primary e-mail. If set to true, the user can log-in with credentials and/or magic link, if enabled in the project settings.', exampleValue: true } }),
26
+ /**
27
+ * @deprecated
28
+ */
29
+ auth_with_email: fieldSchema.yupBoolean().required().meta({ openapiField: { hidden: true, description: 'Whether the user can authenticate with their primary e-mail. If set to true, the user can log-in with credentials and/or magic link, if enabled in the project settings.', exampleValue: true } }),
30
+ /**
31
+ * @deprecated
32
+ */
33
+ requires_totp_mfa: fieldSchema.yupBoolean().required().meta({ openapiField: { hidden: true, description: 'Whether the user is required to use TOTP MFA to sign in', exampleValue: false } }),
34
+ /**
35
+ * @deprecated
36
+ */
26
37
  oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({
27
38
  id: fieldSchema.yupString().required(),
28
39
  account_id: fieldSchema.yupString().required(),
29
40
  email: fieldSchema.yupString().nullable(),
30
- }).required()).required().meta({ openapiField: { description: 'A list of OAuth providers connected to this account', exampleValue: [{ id: 'google', account_id: '12345', email: 'john.doe@gmail.com' }] } }),
41
+ }).required()).required().meta({ openapiField: { hidden: true, description: 'A list of OAuth providers connected to this account', exampleValue: [{ id: 'google', account_id: '12345', email: 'john.doe@gmail.com' }] } }),
42
+ auth_methods: fieldSchema.yupArray(fieldSchema.yupUnion(fieldSchema.yupObject({
43
+ type: fieldSchema.yupString().oneOf(['password']).required(),
44
+ identifier: fieldSchema.yupString().required(),
45
+ }).required(), fieldSchema.yupObject({
46
+ type: fieldSchema.yupString().oneOf(['otp']).required(),
47
+ contact_channel: fieldSchema.yupObject({
48
+ type: fieldSchema.yupString().oneOf(['email']).required(),
49
+ email: fieldSchema.yupString().required(),
50
+ }).required(),
51
+ }).required(), fieldSchema.yupObject({
52
+ type: fieldSchema.yupString().oneOf(['oauth']).required(),
53
+ provider: fieldSchema.userOAuthProviderSchema.required(),
54
+ }).required())).required().meta({ openapiField: { hidden: true, description: 'A list of authentication methods available for this user to sign in with', exampleValue: [{ "contact_channel": { "email": "john.doe@gmail.com", "type": "email", }, "type": "otp", }] } }),
55
+ connected_accounts: fieldSchema.yupArray(fieldSchema.yupUnion(fieldSchema.yupObject({
56
+ type: fieldSchema.yupString().oneOf(['oauth']).required(),
57
+ provider: fieldSchema.userOAuthProviderSchema.required(),
58
+ }).required())).required().meta({ openapiField: { hidden: true, description: 'A list of connected accounts to this user', exampleValue: [{ "provider": { "provider_user_id": "12345", "type": "google", }, "type": "oauth", }] } }),
31
59
  client_metadata: fieldSchema.userClientMetadataSchema,
32
60
  server_metadata: fieldSchema.userServerMetadataSchema,
33
61
  }).required();
@@ -1,8 +1,8 @@
1
1
  import { CrudTypeOf } from "../../crud";
2
2
  export type EmailTemplateType = typeof emailTemplateTypes[number];
3
- export declare const emailTemplateTypes: readonly ["EMAIL_VERIFICATION", "PASSWORD_RESET", "MAGIC_LINK"];
3
+ export declare const emailTemplateTypes: readonly ["EMAIL_VERIFICATION", "PASSWORD_RESET", "MAGIC_LINK", "TEAM_INVITATION"];
4
4
  export declare const emailTemplateServerReadSchema: import("yup").ObjectSchema<{
5
- type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | undefined>;
5
+ type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | "TEAM_INVITATION" | undefined>;
6
6
  subject: string;
7
7
  content: {};
8
8
  }, import("yup").AnyObject, {
@@ -19,7 +19,7 @@ export declare const emailTemplateCrudServerUpdateSchema: import("yup").ObjectSc
19
19
  }, "">;
20
20
  export declare const emailTemplateCrudServerDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
21
21
  export declare const emailTemplateCrudServerCreateSchema: import("yup").ObjectSchema<{
22
- type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | undefined>;
22
+ type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | "TEAM_INVITATION" | undefined>;
23
23
  content: {};
24
24
  subject: string;
25
25
  }, import("yup").AnyObject, {
@@ -29,7 +29,7 @@ export declare const emailTemplateCrudServerCreateSchema: import("yup").ObjectSc
29
29
  }, "">;
30
30
  export declare const emailTemplateCrud: import("../../crud").CrudSchemaFromOptions<{
31
31
  serverReadSchema: import("yup").ObjectSchema<{
32
- type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | undefined>;
32
+ type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | "TEAM_INVITATION" | undefined>;
33
33
  subject: string;
34
34
  content: {};
35
35
  }, import("yup").AnyObject, {
@@ -45,7 +45,7 @@ export declare const emailTemplateCrud: import("../../crud").CrudSchemaFromOptio
45
45
  subject: undefined;
46
46
  }, "">;
47
47
  serverCreateSchema: import("yup").ObjectSchema<{
48
- type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | undefined>;
48
+ type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | "TEAM_INVITATION" | undefined>;
49
49
  content: {};
50
50
  subject: string;
51
51
  }, import("yup").AnyObject, {
@@ -1,6 +1,6 @@
1
1
  import { createCrud } from "../../crud";
2
2
  import { jsonSchema, yupMixed, yupObject, yupString } from "../../schema-fields";
3
- export const emailTemplateTypes = ['EMAIL_VERIFICATION', 'PASSWORD_RESET', 'MAGIC_LINK'];
3
+ export const emailTemplateTypes = ['EMAIL_VERIFICATION', 'PASSWORD_RESET', 'MAGIC_LINK', 'TEAM_INVITATION'];
4
4
  export const emailTemplateServerReadSchema = yupObject({
5
5
  type: yupString().oneOf(emailTemplateTypes).required(),
6
6
  subject: yupString().required(),
@@ -28,13 +28,14 @@ export declare class StackServerInterface extends StackClientInterface {
28
28
  refreshToken: RefreshToken | null;
29
29
  } | null;
30
30
  }, InstanceType<E>>>;
31
+ createServerUser(data: UsersCrud['Server']['Create']): Promise<UsersCrud['Server']['Read']>;
31
32
  getServerUserByToken(session: InternalSession): Promise<CurrentUserCrud['Server']['Read'] | null>;
32
33
  getServerUserById(userId: string): Promise<Result<UsersCrud['Server']['Read']>>;
33
34
  listServerTeamPermissions(options: {
34
35
  userId?: string;
35
36
  teamId?: string;
36
37
  recursive: boolean;
37
- }, session: InternalSession): Promise<TeamPermissionsCrud['Server']['Read'][]>;
38
+ }, session: InternalSession | null): Promise<TeamPermissionsCrud['Server']['Read'][]>;
38
39
  listServerUsers(): Promise<UsersCrud['Server']['Read'][]>;
39
40
  listServerTeams(options?: {
40
41
  userId?: string;
@@ -57,11 +58,6 @@ export declare class StackServerInterface extends StackClientInterface {
57
58
  accessToken: string;
58
59
  refreshToken: string;
59
60
  }>;
60
- listServerTeamMemberPermissions(options: {
61
- teamId: string;
62
- userId: string;
63
- recursive: boolean;
64
- }): Promise<TeamPermissionsCrud['Server']['Read'][]>;
65
61
  grantServerTeamUserPermission(teamId: string, userId: string, permissionId: string): Promise<void>;
66
62
  revokeServerTeamUserPermission(teamId: string, userId: string, permissionId: string): Promise<void>;
67
63
  deleteServerServerUser(userId: string): Promise<void>;
@@ -30,6 +30,16 @@ export class StackServerInterface extends StackClientInterface {
30
30
  throw e;
31
31
  }
32
32
  }
33
+ async createServerUser(data) {
34
+ const response = await this.sendServerRequest("/users", {
35
+ method: "POST",
36
+ headers: {
37
+ "content-type": "application/json",
38
+ },
39
+ body: JSON.stringify(data),
40
+ }, null);
41
+ return await response.json();
42
+ }
33
43
  async getServerUserByToken(session) {
34
44
  const responseOrError = await this.sendServerRequestAndCatchKnownError("/users/me", {}, session, [KnownErrors.CannotGetOwnUserWithoutUser]);
35
45
  if (responseOrError.status === "error") {
@@ -159,11 +169,6 @@ export class StackServerInterface extends StackClientInterface {
159
169
  refreshToken: result.refresh_token,
160
170
  };
161
171
  }
162
- async listServerTeamMemberPermissions(options) {
163
- const response = await this.sendServerRequest(`/team-permissions?team_id=${options.teamId}&user_id=${options.userId}&recursive=${options.recursive}`, {}, null);
164
- const result = await response.json();
165
- return result.items;
166
- }
167
172
  async grantServerTeamUserPermission(teamId, userId, permissionId) {
168
173
  await this.sendServerRequest(`/team-permissions/${teamId}/${userId}/${permissionId}`, {
169
174
  method: "POST",
@@ -26,11 +26,35 @@ export declare const webhookEvents: readonly [{
26
26
  signed_up_at_millis: number;
27
27
  has_password: NonNullable<boolean | undefined>;
28
28
  auth_with_email: NonNullable<boolean | undefined>;
29
+ requires_totp_mfa: NonNullable<boolean | undefined>;
29
30
  oauth_providers: {
30
31
  email?: string | null | undefined;
31
32
  id: string;
32
33
  account_id: string;
33
34
  }[];
35
+ auth_methods: ({
36
+ type: "password";
37
+ identifier: string;
38
+ } | {
39
+ type: "otp";
40
+ contact_channel: {
41
+ type: "email";
42
+ email: string;
43
+ };
44
+ } | {
45
+ type: "oauth";
46
+ provider: {
47
+ type: string;
48
+ provider_user_id: string;
49
+ };
50
+ })[];
51
+ connected_accounts: {
52
+ type: "oauth";
53
+ provider: {
54
+ type: string;
55
+ provider_user_id: string;
56
+ };
57
+ }[];
34
58
  client_metadata: {} | null;
35
59
  server_metadata: {} | null;
36
60
  }, yup.AnyObject, {
@@ -49,7 +73,10 @@ export declare const webhookEvents: readonly [{
49
73
  signed_up_at_millis: undefined;
50
74
  has_password: undefined;
51
75
  auth_with_email: undefined;
76
+ requires_totp_mfa: undefined;
52
77
  oauth_providers: undefined;
78
+ auth_methods: undefined;
79
+ connected_accounts: undefined;
53
80
  client_metadata: undefined;
54
81
  server_metadata: undefined;
55
82
  }, "">;
@@ -76,11 +103,35 @@ export declare const webhookEvents: readonly [{
76
103
  signed_up_at_millis: number;
77
104
  has_password: NonNullable<boolean | undefined>;
78
105
  auth_with_email: NonNullable<boolean | undefined>;
106
+ requires_totp_mfa: NonNullable<boolean | undefined>;
79
107
  oauth_providers: {
80
108
  email?: string | null | undefined;
81
109
  id: string;
82
110
  account_id: string;
83
111
  }[];
112
+ auth_methods: ({
113
+ type: "password";
114
+ identifier: string;
115
+ } | {
116
+ type: "otp";
117
+ contact_channel: {
118
+ type: "email";
119
+ email: string;
120
+ };
121
+ } | {
122
+ type: "oauth";
123
+ provider: {
124
+ type: string;
125
+ provider_user_id: string;
126
+ };
127
+ })[];
128
+ connected_accounts: {
129
+ type: "oauth";
130
+ provider: {
131
+ type: string;
132
+ provider_user_id: string;
133
+ };
134
+ }[];
84
135
  client_metadata: {} | null;
85
136
  server_metadata: {} | null;
86
137
  }, yup.AnyObject, {
@@ -99,7 +150,10 @@ export declare const webhookEvents: readonly [{
99
150
  signed_up_at_millis: undefined;
100
151
  has_password: undefined;
101
152
  auth_with_email: undefined;
153
+ requires_totp_mfa: undefined;
102
154
  oauth_providers: undefined;
155
+ auth_methods: undefined;
156
+ connected_accounts: undefined;
103
157
  client_metadata: undefined;
104
158
  server_metadata: undefined;
105
159
  }, "">;
@@ -245,6 +245,9 @@ export declare const KnownErrors: {
245
245
  ProjectNotFound: KnownErrorConstructor<KnownError & KnownErrorBrand<"PROJECT_NOT_FOUND">, [projectId: string]> & {
246
246
  errorCode: "PROJECT_NOT_FOUND";
247
247
  };
248
+ SignUpNotEnabled: KnownErrorConstructor<KnownError & KnownErrorBrand<"SIGN_UP_NOT_ENABLED">, []> & {
249
+ errorCode: "SIGN_UP_NOT_ENABLED";
250
+ };
248
251
  PasswordAuthenticationNotEnabled: KnownErrorConstructor<KnownError & KnownErrorBrand<"PASSWORD_AUTHENTICATION_NOT_ENABLED">, []> & {
249
252
  errorCode: "PASSWORD_AUTHENTICATION_NOT_ENABLED";
250
253
  };
@@ -345,6 +348,12 @@ export declare const KnownErrors: {
345
348
  OAuthProviderNotFoundOrNotEnabled: KnownErrorConstructor<KnownError & KnownErrorBrand<"OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED">, []> & {
346
349
  errorCode: "OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED";
347
350
  };
351
+ MultiFactorAuthenticationRequired: KnownErrorConstructor<KnownError & KnownErrorBrand<"MULTI_FACTOR_AUTHENTICATION_REQUIRED">, [attemptCode: string]> & {
352
+ errorCode: "MULTI_FACTOR_AUTHENTICATION_REQUIRED";
353
+ };
354
+ InvalidTotpCode: KnownErrorConstructor<KnownError & KnownErrorBrand<"INVALID_TOTP_CODE">, []> & {
355
+ errorCode: "INVALID_TOTP_CODE";
356
+ };
348
357
  UserAuthenticationRequired: KnownErrorConstructor<KnownError & KnownErrorBrand<"USER_AUTHENTICATION_REQUIRED">, []> & {
349
358
  errorCode: "USER_AUTHENTICATION_REQUIRED";
350
359
  };
@@ -360,5 +369,11 @@ export declare const KnownErrors: {
360
369
  InvalidStandardOAuthProviderId: KnownErrorConstructor<KnownError & KnownErrorBrand<"INVALID_STANDARD_OAUTH_PROVIDER_ID">, [any]> & {
361
370
  errorCode: "INVALID_STANDARD_OAUTH_PROVIDER_ID";
362
371
  };
372
+ InvalidAuthorizationCode: KnownErrorConstructor<KnownError & KnownErrorBrand<"INVALID_AUTHORIZATION_CODE">, []> & {
373
+ errorCode: "INVALID_AUTHORIZATION_CODE";
374
+ };
375
+ TeamPermissionNotFound: KnownErrorConstructor<KnownError & KnownErrorBrand<"TEAM_PERMISSION_NOT_FOUND">, [any, any, any]> & {
376
+ errorCode: "TEAM_PERMISSION_NOT_FOUND";
377
+ };
363
378
  };
364
379
  export {};
@@ -320,6 +320,10 @@ const ProjectNotFound = createKnownErrorConstructor(KnownError, "PROJECT_NOT_FOU
320
320
  },
321
321
  ];
322
322
  }, (json) => [json.project_id]);
323
+ const SignUpNotEnabled = createKnownErrorConstructor(KnownError, "SIGN_UP_NOT_ENABLED", () => [
324
+ 400,
325
+ "Creation of new accounts is not enabled for this project. Please ask the project owner to enable it.",
326
+ ], () => []);
323
327
  const PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSWORD_AUTHENTICATION_NOT_ENABLED", () => [
324
328
  400,
325
329
  "Password authentication is not enabled for this project.",
@@ -471,6 +475,17 @@ const OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(KnownError
471
475
  400,
472
476
  "The OAuth provider is not found or not enabled.",
473
477
  ], () => []);
478
+ const MultiFactorAuthenticationRequired = createKnownErrorConstructor(KnownError, "MULTI_FACTOR_AUTHENTICATION_REQUIRED", (attemptCode) => [
479
+ 400,
480
+ `Multi-factor authentication is required for this user.`,
481
+ {
482
+ attempt_code: attemptCode,
483
+ },
484
+ ], (json) => [json.attempt_code]);
485
+ const InvalidTotpCode = createKnownErrorConstructor(KnownError, "INVALID_TOTP_CODE", () => [
486
+ 400,
487
+ "The TOTP code is invalid. Please try again.",
488
+ ], () => []);
474
489
  const UserAuthenticationRequired = createKnownErrorConstructor(KnownError, "USER_AUTHENTICATION_REQUIRED", () => [
475
490
  401,
476
491
  "User authentication required for this endpoint.",
@@ -488,6 +503,15 @@ const TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PER
488
503
  permission_id: permissionId,
489
504
  },
490
505
  ], (json) => [json.team_id, json.user_id, json.permission_id]);
506
+ const TeamPermissionNotFound = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_NOT_FOUND", (teamId, userId, permissionId) => [
507
+ 401,
508
+ `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
509
+ {
510
+ team_id: teamId,
511
+ user_id: userId,
512
+ permission_id: permissionId,
513
+ },
514
+ ], (json) => [json.team_id, json.user_id, json.permission_id]);
491
515
  const InvalidSharedOAuthProviderId = createKnownErrorConstructor(KnownError, "INVALID_SHARED_OAUTH_PROVIDER_ID", (providerId) => [
492
516
  400,
493
517
  `The shared OAuth provider with ID ${providerId} is not valid.`,
@@ -502,6 +526,10 @@ const InvalidStandardOAuthProviderId = createKnownErrorConstructor(KnownError, "
502
526
  provider_id: providerId,
503
527
  },
504
528
  ], (json) => [json.provider_id]);
529
+ const InvalidAuthorizationCode = createKnownErrorConstructor(KnownError, "INVALID_AUTHORIZATION_CODE", () => [
530
+ 400,
531
+ "The given authorization code is invalid.",
532
+ ], () => []);
505
533
  export const KnownErrors = {
506
534
  UnsupportedError,
507
535
  BodyParsingError,
@@ -548,6 +576,7 @@ export const KnownErrors = {
548
576
  UserNotFound,
549
577
  ApiKeyNotFound,
550
578
  ProjectNotFound,
579
+ SignUpNotEnabled,
551
580
  PasswordAuthenticationNotEnabled,
552
581
  EmailPasswordMismatch,
553
582
  RedirectUrlNotWhitelisted,
@@ -578,11 +607,15 @@ export const KnownErrors = {
578
607
  UserAlreadyConnectedToAnotherOAuthConnection,
579
608
  OuterOAuthTimeout,
580
609
  OAuthProviderNotFoundOrNotEnabled,
610
+ MultiFactorAuthenticationRequired,
611
+ InvalidTotpCode,
581
612
  UserAuthenticationRequired,
582
613
  TeamMembershipAlreadyExists,
583
614
  TeamPermissionRequired,
584
615
  InvalidSharedOAuthProviderId,
585
616
  InvalidStandardOAuthProviderId,
617
+ InvalidAuthorizationCode,
618
+ TeamPermissionNotFound,
586
619
  };
587
620
  // ensure that all known error codes are unique
588
621
  const knownErrorCodes = new Set();
@@ -12,6 +12,7 @@ export declare function yupMixed<A extends {}>(...args: Parameters<typeof yup.mi
12
12
  export declare function yupArray<A extends yup.Maybe<yup.AnyObject> = yup.AnyObject, B = any>(...args: Parameters<typeof yup.array<A, B>>): yup.ArraySchema<B[] | undefined, A, undefined, "">;
13
13
  export declare function yupTuple<T extends [unknown, ...unknown[]]>(...args: Parameters<typeof yup.tuple<T>>): yup.TupleSchema<T | undefined, yup.AnyObject, undefined, "">;
14
14
  export declare function yupObject<A extends yup.Maybe<yup.AnyObject>, B extends yup.ObjectShape>(...args: Parameters<typeof yup.object<A, B>>): yup.ObjectSchema<yup.TypeFromShape<B, yup.AnyObject> extends infer T ? T extends yup.TypeFromShape<B, yup.AnyObject> ? T extends {} ? { [k in keyof T]: T[k]; } : T : never : never, yup.AnyObject, yup.DefaultFromShape<B> extends infer T_1 ? T_1 extends yup.DefaultFromShape<B> ? T_1 extends {} ? { [k_1 in keyof T_1]: T_1[k_1]; } : T_1 : never : never, "">;
15
+ export declare function yupUnion<T extends yup.ISchema<any>[]>(...args: T): yup.ISchema<yup.InferType<T[number]>>;
15
16
  export declare const adaptSchema: yup.MixedSchema<typeof StackAdaptSentinel | undefined, yup.AnyObject, undefined, "">;
16
17
  /**
17
18
  * Yup's URL schema does not recognize some URLs (including `http://localhost`) as a valid URL. This schema is a workaround for that.
@@ -21,6 +22,7 @@ export declare const jsonSchema: yup.MixedSchema<{} | null, yup.AnyObject, undef
21
22
  export declare const jsonStringSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
22
23
  export declare const jsonStringOrEmptySchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
23
24
  export declare const emailSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
25
+ export declare const base64Schema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
24
26
  export declare const clientOrHigherAuthTypeSchema: yup.StringSchema<"client" | "server" | "admin" | undefined, yup.AnyObject, undefined, "">;
25
27
  export declare const serverOrHigherAuthTypeSchema: yup.StringSchema<"server" | "admin" | undefined, yup.AnyObject, undefined, "">;
26
28
  export declare const adminAuthTypeSchema: yup.StringSchema<"admin" | undefined, yup.AnyObject, undefined, "">;
@@ -34,6 +36,7 @@ export declare const projectConfigIdSchema: yup.StringSchema<string | undefined,
34
36
  export declare const projectAllowLocalhostSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
35
37
  export declare const projectCreateTeamOnSignUpSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
36
38
  export declare const projectMagicLinkEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
39
+ export declare const projectSignUpEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
37
40
  export declare const projectCredentialEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
38
41
  export declare const oauthIdSchema: yup.StringSchema<"google" | "github" | "facebook" | "microsoft" | "spotify" | undefined, yup.AnyObject, undefined, "">;
39
42
  export declare const oauthEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
@@ -63,6 +66,13 @@ export declare const profileImageUrlSchema: yup.StringSchema<string | undefined,
63
66
  export declare const signedUpAtMillisSchema: yup.NumberSchema<number | undefined, yup.AnyObject, undefined, "">;
64
67
  export declare const userClientMetadataSchema: yup.MixedSchema<{} | null, yup.AnyObject, undefined, "">;
65
68
  export declare const userServerMetadataSchema: yup.MixedSchema<{} | null, yup.AnyObject, undefined, "">;
69
+ export declare const userOAuthProviderSchema: yup.ObjectSchema<{
70
+ type: string;
71
+ provider_user_id: string;
72
+ }, yup.AnyObject, {
73
+ type: undefined;
74
+ provider_user_id: undefined;
75
+ }, "">;
66
76
  export declare const signInEmailSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
67
77
  export declare const emailOtpSignInCallbackUrlSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
68
78
  export declare const emailVerificationCallbackUrlSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
@@ -90,6 +100,8 @@ export declare const teamProfileImageUrlSchema: yup.StringSchema<string | undefi
90
100
  export declare const teamClientMetadataSchema: yup.MixedSchema<{} | null, yup.AnyObject, undefined, "">;
91
101
  export declare const teamServerMetadataSchema: yup.MixedSchema<{} | null, yup.AnyObject, undefined, "">;
92
102
  export declare const teamCreatedAtMillisSchema: yup.NumberSchema<number | undefined, yup.AnyObject, undefined, "">;
103
+ export declare const teamInvitationEmailSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
104
+ export declare const teamInvitationCallbackUrlSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
93
105
  export declare const teamMemberDisplayNameSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
94
106
  export declare const teamMemberProfileImageUrlSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
95
107
  export declare function yupRequiredWhen<S extends yup.AnyObject>(schema: S, triggerName: string, isValue: any): S;