@stackframe/stack-shared 2.5.17 → 2.5.19

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 (32) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/interface/adminInterface.d.ts +1 -0
  3. package/dist/interface/adminInterface.js +5 -0
  4. package/dist/interface/clientInterface.d.ts +33 -0
  5. package/dist/interface/clientInterface.js +96 -4
  6. package/dist/interface/crud/current-user.d.ts +8 -0
  7. package/dist/interface/crud/current-user.js +2 -0
  8. package/dist/interface/crud/email-templates.d.ts +5 -5
  9. package/dist/interface/crud/email-templates.js +1 -1
  10. package/dist/interface/crud/projects.d.ts +42 -7
  11. package/dist/interface/crud/projects.js +22 -9
  12. package/dist/interface/crud/team-invitation-details.d.ts +25 -0
  13. package/dist/interface/crud/team-invitation-details.js +17 -0
  14. package/dist/interface/crud/team-member-profiles.d.ts +166 -0
  15. package/dist/interface/crud/team-member-profiles.js +5 -0
  16. package/dist/interface/crud/users.d.ts +16 -0
  17. package/dist/interface/crud/users.js +7 -2
  18. package/dist/interface/crud-deprecated/email-templates.d.ts +5 -5
  19. package/dist/interface/crud-deprecated/email-templates.js +1 -1
  20. package/dist/interface/serverInterface.d.ts +12 -4
  21. package/dist/interface/serverInterface.js +27 -4
  22. package/dist/interface/webhooks.d.ts +4 -0
  23. package/dist/known-errors.d.ts +12 -0
  24. package/dist/known-errors.js +29 -1
  25. package/dist/schema-fields.d.ts +5 -0
  26. package/dist/schema-fields.js +22 -10
  27. package/dist/utils/bytes.d.ts +4 -0
  28. package/dist/utils/bytes.js +36 -0
  29. package/dist/utils/crypto.d.ts +1 -1
  30. package/dist/utils/errors.d.ts +7 -1
  31. package/dist/utils/errors.js +7 -1
  32. package/package.json +2 -2
@@ -0,0 +1,25 @@
1
+ import { CrudTypeOf } from "../../crud";
2
+ export declare const teamInvitationDetailsClientReadSchema: import("yup").ObjectSchema<{
3
+ team_id: string;
4
+ team_display_name: string;
5
+ }, import("yup").AnyObject, {
6
+ team_id: undefined;
7
+ team_display_name: undefined;
8
+ }, "">;
9
+ export declare const teamInvitationDetailsCrud: import("../../crud").CrudSchemaFromOptions<{
10
+ clientReadSchema: import("yup").ObjectSchema<{
11
+ team_id: string;
12
+ team_display_name: string;
13
+ }, import("yup").AnyObject, {
14
+ team_id: undefined;
15
+ team_display_name: undefined;
16
+ }, "">;
17
+ docs: {
18
+ clientRead: {
19
+ summary: string;
20
+ description: string;
21
+ tags: string[];
22
+ };
23
+ };
24
+ }>;
25
+ export type TeamInvitationDetailsCrud = CrudTypeOf<typeof teamInvitationDetailsCrud>;
@@ -0,0 +1,17 @@
1
+ import { createCrud } from "../../crud";
2
+ import * as schemaFields from "../../schema-fields";
3
+ import { yupObject } from "../../schema-fields";
4
+ export const teamInvitationDetailsClientReadSchema = yupObject({
5
+ team_id: schemaFields.teamIdSchema.required(),
6
+ team_display_name: schemaFields.teamDisplayNameSchema.required(),
7
+ }).required();
8
+ export const teamInvitationDetailsCrud = createCrud({
9
+ clientReadSchema: teamInvitationDetailsClientReadSchema,
10
+ docs: {
11
+ clientRead: {
12
+ summary: "Get the team details with invitation code",
13
+ description: "",
14
+ tags: ["Teams"],
15
+ },
16
+ },
17
+ });
@@ -10,6 +10,89 @@ export declare const teamMemberProfilesCrudClientReadSchema: import("yup").Objec
10
10
  display_name: undefined;
11
11
  profile_image_url: undefined;
12
12
  }, "">;
13
+ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").ObjectSchema<NonNullable<{
14
+ team_id: string;
15
+ user_id: string;
16
+ display_name: string | null;
17
+ profile_image_url: string | null;
18
+ } & {
19
+ user: {
20
+ id: string;
21
+ display_name: string | null;
22
+ oauth_providers: {
23
+ email?: string | null | undefined;
24
+ id: string;
25
+ account_id: string;
26
+ }[];
27
+ primary_email: string | null;
28
+ profile_image_url: string | null;
29
+ client_metadata: {} | null;
30
+ server_metadata: {} | null;
31
+ primary_email_verified: NonNullable<boolean | undefined>;
32
+ selected_team_id: string | null;
33
+ selected_team: {
34
+ id: string;
35
+ created_at_millis: number;
36
+ display_name: string;
37
+ profile_image_url: string | null;
38
+ } | null;
39
+ signed_up_at_millis: number;
40
+ has_password: NonNullable<boolean | undefined>;
41
+ auth_with_email: NonNullable<boolean | undefined>;
42
+ requires_totp_mfa: NonNullable<boolean | undefined>;
43
+ auth_methods: ({
44
+ type: "password";
45
+ identifier: string;
46
+ } | {
47
+ type: "otp";
48
+ contact_channel: {
49
+ type: "email";
50
+ email: string;
51
+ };
52
+ } | {
53
+ type: "oauth";
54
+ provider: {
55
+ type: string;
56
+ provider_user_id: string;
57
+ };
58
+ })[];
59
+ connected_accounts: {
60
+ type: "oauth";
61
+ provider: {
62
+ type: string;
63
+ provider_user_id: string;
64
+ };
65
+ }[];
66
+ };
67
+ }>, import("yup").AnyObject, {
68
+ team_id: undefined;
69
+ user_id: undefined;
70
+ display_name: undefined;
71
+ profile_image_url: undefined;
72
+ user: {
73
+ id: undefined;
74
+ primary_email: undefined;
75
+ primary_email_verified: undefined;
76
+ display_name: undefined;
77
+ selected_team: {
78
+ id: undefined;
79
+ display_name: undefined;
80
+ profile_image_url: undefined;
81
+ created_at_millis: undefined;
82
+ };
83
+ selected_team_id: undefined;
84
+ profile_image_url: undefined;
85
+ signed_up_at_millis: undefined;
86
+ has_password: undefined;
87
+ auth_with_email: undefined;
88
+ requires_totp_mfa: undefined;
89
+ oauth_providers: undefined;
90
+ auth_methods: undefined;
91
+ connected_accounts: undefined;
92
+ client_metadata: undefined;
93
+ server_metadata: undefined;
94
+ };
95
+ }, "">;
13
96
  export declare const teamMemberProfilesCrudClientUpdateSchema: import("yup").ObjectSchema<{
14
97
  display_name: string | undefined;
15
98
  profile_image_url: string | null | undefined;
@@ -29,6 +112,89 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
29
112
  display_name: undefined;
30
113
  profile_image_url: undefined;
31
114
  }, "">;
115
+ serverReadSchema: import("yup").ObjectSchema<NonNullable<{
116
+ team_id: string;
117
+ user_id: string;
118
+ display_name: string | null;
119
+ profile_image_url: string | null;
120
+ } & {
121
+ user: {
122
+ id: string;
123
+ display_name: string | null;
124
+ oauth_providers: {
125
+ email?: string | null | undefined;
126
+ id: string;
127
+ account_id: string;
128
+ }[];
129
+ primary_email: string | null;
130
+ profile_image_url: string | null;
131
+ client_metadata: {} | null;
132
+ server_metadata: {} | null;
133
+ primary_email_verified: NonNullable<boolean | undefined>;
134
+ selected_team_id: string | null;
135
+ selected_team: {
136
+ id: string;
137
+ created_at_millis: number;
138
+ display_name: string;
139
+ profile_image_url: string | null;
140
+ } | null;
141
+ signed_up_at_millis: number;
142
+ has_password: NonNullable<boolean | undefined>;
143
+ auth_with_email: NonNullable<boolean | undefined>;
144
+ requires_totp_mfa: NonNullable<boolean | undefined>;
145
+ auth_methods: ({
146
+ type: "password";
147
+ identifier: string;
148
+ } | {
149
+ type: "otp";
150
+ contact_channel: {
151
+ type: "email";
152
+ email: string;
153
+ };
154
+ } | {
155
+ type: "oauth";
156
+ provider: {
157
+ type: string;
158
+ provider_user_id: string;
159
+ };
160
+ })[];
161
+ connected_accounts: {
162
+ type: "oauth";
163
+ provider: {
164
+ type: string;
165
+ provider_user_id: string;
166
+ };
167
+ }[];
168
+ };
169
+ }>, import("yup").AnyObject, {
170
+ team_id: undefined;
171
+ user_id: undefined;
172
+ display_name: undefined;
173
+ profile_image_url: undefined;
174
+ user: {
175
+ id: undefined;
176
+ primary_email: undefined;
177
+ primary_email_verified: undefined;
178
+ display_name: undefined;
179
+ selected_team: {
180
+ id: undefined;
181
+ display_name: undefined;
182
+ profile_image_url: undefined;
183
+ created_at_millis: undefined;
184
+ };
185
+ selected_team_id: undefined;
186
+ profile_image_url: undefined;
187
+ signed_up_at_millis: undefined;
188
+ has_password: undefined;
189
+ auth_with_email: undefined;
190
+ requires_totp_mfa: undefined;
191
+ oauth_providers: undefined;
192
+ auth_methods: undefined;
193
+ connected_accounts: undefined;
194
+ client_metadata: undefined;
195
+ server_metadata: undefined;
196
+ };
197
+ }, "">;
32
198
  clientUpdateSchema: import("yup").ObjectSchema<{
33
199
  display_name: string | undefined;
34
200
  profile_image_url: string | null | undefined;
@@ -1,18 +1,23 @@
1
1
  import { createCrud } from "../../crud";
2
2
  import * as schemaFields from "../../schema-fields";
3
3
  import { yupObject } from "../../schema-fields";
4
+ import { usersCrudServerReadSchema } from "./users";
4
5
  export const teamMemberProfilesCrudClientReadSchema = yupObject({
5
6
  team_id: schemaFields.teamIdSchema.required(),
6
7
  user_id: schemaFields.userIdSchema.required(),
7
8
  display_name: schemaFields.teamMemberDisplayNameSchema.nullable().defined(),
8
9
  profile_image_url: schemaFields.teamMemberProfileImageUrlSchema.nullable().defined(),
9
10
  }).required();
11
+ export const teamMemberProfilesCrudServerReadSchema = teamMemberProfilesCrudClientReadSchema.concat(yupObject({
12
+ user: usersCrudServerReadSchema.required(),
13
+ })).required();
10
14
  export const teamMemberProfilesCrudClientUpdateSchema = yupObject({
11
15
  display_name: schemaFields.teamMemberDisplayNameSchema.optional(),
12
16
  profile_image_url: schemaFields.teamMemberProfileImageUrlSchema.nullable().optional(),
13
17
  }).required();
14
18
  export const teamMemberProfilesCrud = createCrud({
15
19
  clientReadSchema: teamMemberProfilesCrudClientReadSchema,
20
+ serverReadSchema: teamMemberProfilesCrudServerReadSchema,
16
21
  clientUpdateSchema: teamMemberProfilesCrudClientUpdateSchema,
17
22
  docs: {
18
23
  clientList: {
@@ -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,6 +38,7 @@ 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;
@@ -82,6 +85,7 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
82
85
  signed_up_at_millis: undefined;
83
86
  has_password: undefined;
84
87
  auth_with_email: undefined;
88
+ requires_totp_mfa: undefined;
85
89
  oauth_providers: undefined;
86
90
  auth_methods: undefined;
87
91
  connected_accounts: undefined;
@@ -97,6 +101,7 @@ export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
97
101
  primary_email_verified: boolean | undefined;
98
102
  primary_email_auth_enabled: boolean | undefined;
99
103
  password: string | null | undefined;
104
+ totp_secret_base64: string | null | undefined;
100
105
  selected_team_id: string | null | undefined;
101
106
  } & {
102
107
  oauth_providers: {
@@ -113,6 +118,7 @@ export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
113
118
  primary_email_verified: undefined;
114
119
  primary_email_auth_enabled: undefined;
115
120
  password: undefined;
121
+ totp_secret_base64: undefined;
116
122
  selected_team_id: undefined;
117
123
  oauth_providers: undefined;
118
124
  }, "">;
@@ -134,6 +140,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
134
140
  signed_up_at_millis: number;
135
141
  has_password: NonNullable<boolean | undefined>;
136
142
  auth_with_email: NonNullable<boolean | undefined>;
143
+ requires_totp_mfa: NonNullable<boolean | undefined>;
137
144
  oauth_providers: {
138
145
  email?: string | null | undefined;
139
146
  id: string;
@@ -180,6 +187,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
180
187
  signed_up_at_millis: undefined;
181
188
  has_password: undefined;
182
189
  auth_with_email: undefined;
190
+ requires_totp_mfa: undefined;
183
191
  oauth_providers: undefined;
184
192
  auth_methods: undefined;
185
193
  connected_accounts: undefined;
@@ -195,6 +203,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
195
203
  primary_email_verified: boolean | undefined;
196
204
  primary_email_auth_enabled: boolean | undefined;
197
205
  password: string | null | undefined;
206
+ totp_secret_base64: string | null | undefined;
198
207
  selected_team_id: string | null | undefined;
199
208
  }, import("yup").AnyObject, {
200
209
  display_name: undefined;
@@ -205,6 +214,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
205
214
  primary_email_verified: undefined;
206
215
  primary_email_auth_enabled: undefined;
207
216
  password: undefined;
217
+ totp_secret_base64: undefined;
208
218
  selected_team_id: undefined;
209
219
  }, "">;
210
220
  serverCreateSchema: import("yup").ObjectSchema<{
@@ -216,6 +226,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
216
226
  primary_email_verified: boolean | undefined;
217
227
  primary_email_auth_enabled: boolean | undefined;
218
228
  password: string | null | undefined;
229
+ totp_secret_base64: string | null | undefined;
219
230
  selected_team_id: string | null | undefined;
220
231
  } & {
221
232
  oauth_providers: {
@@ -232,6 +243,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
232
243
  primary_email_verified: undefined;
233
244
  primary_email_auth_enabled: undefined;
234
245
  password: undefined;
246
+ totp_secret_base64: undefined;
235
247
  selected_team_id: undefined;
236
248
  oauth_providers: undefined;
237
249
  }, "">;
@@ -283,6 +295,7 @@ export declare const userCreatedWebhookEvent: {
283
295
  signed_up_at_millis: number;
284
296
  has_password: NonNullable<boolean | undefined>;
285
297
  auth_with_email: NonNullable<boolean | undefined>;
298
+ requires_totp_mfa: NonNullable<boolean | undefined>;
286
299
  oauth_providers: {
287
300
  email?: string | null | undefined;
288
301
  id: string;
@@ -329,6 +342,7 @@ export declare const userCreatedWebhookEvent: {
329
342
  signed_up_at_millis: undefined;
330
343
  has_password: undefined;
331
344
  auth_with_email: undefined;
345
+ requires_totp_mfa: undefined;
332
346
  oauth_providers: undefined;
333
347
  auth_methods: undefined;
334
348
  connected_accounts: undefined;
@@ -359,6 +373,7 @@ export declare const userUpdatedWebhookEvent: {
359
373
  signed_up_at_millis: number;
360
374
  has_password: NonNullable<boolean | undefined>;
361
375
  auth_with_email: NonNullable<boolean | undefined>;
376
+ requires_totp_mfa: NonNullable<boolean | undefined>;
362
377
  oauth_providers: {
363
378
  email?: string | null | undefined;
364
379
  id: string;
@@ -405,6 +420,7 @@ export declare const userUpdatedWebhookEvent: {
405
420
  signed_up_at_millis: undefined;
406
421
  has_password: undefined;
407
422
  auth_with_email: undefined;
423
+ requires_totp_mfa: undefined;
408
424
  oauth_providers: undefined;
409
425
  auth_methods: undefined;
410
426
  connected_accounts: undefined;
@@ -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({
@@ -26,6 +27,10 @@ export const usersCrudServerReadSchema = fieldSchema.yupObject({
26
27
  * @deprecated
27
28
  */
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 } }),
29
34
  /**
30
35
  * @deprecated
31
36
  */
@@ -46,11 +51,11 @@ export const usersCrudServerReadSchema = fieldSchema.yupObject({
46
51
  }).required(), fieldSchema.yupObject({
47
52
  type: fieldSchema.yupString().oneOf(['oauth']).required(),
48
53
  provider: fieldSchema.userOAuthProviderSchema.required(),
49
- }).required())).required().meta({ openapiField: { 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", }] } }),
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", }] } }),
50
55
  connected_accounts: fieldSchema.yupArray(fieldSchema.yupUnion(fieldSchema.yupObject({
51
56
  type: fieldSchema.yupString().oneOf(['oauth']).required(),
52
57
  provider: fieldSchema.userOAuthProviderSchema.required(),
53
- }).required())).required().meta({ openapiField: { description: 'A list of connected accounts to this user', exampleValue: [{ "provider": { "provider_user_id": "12345", "type": "google", }, "type": "oauth", }] } }),
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", }] } }),
54
59
  client_metadata: fieldSchema.userClientMetadataSchema,
55
60
  server_metadata: fieldSchema.userServerMetadataSchema,
56
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(),
@@ -4,6 +4,7 @@ import { Result } from "../utils/results";
4
4
  import { ClientInterfaceOptions, StackClientInterface } from "./clientInterface";
5
5
  import { CurrentUserCrud } from "./crud/current-user";
6
6
  import { ConnectedAccountAccessTokenCrud } from "./crud/oauth";
7
+ import { TeamMemberProfilesCrud } from "./crud/team-member-profiles";
7
8
  import { TeamMembershipsCrud } from "./crud/team-memberships";
8
9
  import { TeamPermissionsCrud } from "./crud/team-permissions";
9
10
  import { TeamsCrud } from "./crud/teams";
@@ -28,13 +29,21 @@ export declare class StackServerInterface extends StackClientInterface {
28
29
  refreshToken: RefreshToken | null;
29
30
  } | null;
30
31
  }, InstanceType<E>>>;
32
+ createServerUser(data: UsersCrud['Server']['Create']): Promise<UsersCrud['Server']['Read']>;
31
33
  getServerUserByToken(session: InternalSession): Promise<CurrentUserCrud['Server']['Read'] | null>;
32
34
  getServerUserById(userId: string): Promise<Result<UsersCrud['Server']['Read']>>;
35
+ listServerTeamMemberProfiles(options: {
36
+ teamId: string;
37
+ }): Promise<TeamMemberProfilesCrud['Server']['Read'][]>;
38
+ getServerTeamMemberProfile(options: {
39
+ teamId: string;
40
+ userId: string;
41
+ }): Promise<TeamMemberProfilesCrud['Client']['Read']>;
33
42
  listServerTeamPermissions(options: {
34
43
  userId?: string;
35
44
  teamId?: string;
36
45
  recursive: boolean;
37
- }, session: InternalSession): Promise<TeamPermissionsCrud['Server']['Read'][]>;
46
+ }, session: InternalSession | null): Promise<TeamPermissionsCrud['Server']['Read'][]>;
38
47
  listServerUsers(): Promise<UsersCrud['Server']['Read'][]>;
39
48
  listServerTeams(options?: {
40
49
  userId?: string;
@@ -57,11 +66,10 @@ export declare class StackServerInterface extends StackClientInterface {
57
66
  accessToken: string;
58
67
  refreshToken: string;
59
68
  }>;
60
- listServerTeamMemberPermissions(options: {
69
+ leaveServerTeam(options: {
61
70
  teamId: string;
62
71
  userId: string;
63
- recursive: boolean;
64
- }): Promise<TeamPermissionsCrud['Server']['Read'][]>;
72
+ }): Promise<void>;
65
73
  grantServerTeamUserPermission(teamId: string, userId: string, permissionId: string): Promise<void>;
66
74
  revokeServerTeamUserPermission(teamId: string, userId: string, permissionId: string): Promise<void>;
67
75
  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") {
@@ -53,6 +63,15 @@ export class StackServerInterface extends StackClientInterface {
53
63
  return Result.error(new Error("Failed to get user"));
54
64
  return Result.ok(user);
55
65
  }
66
+ async listServerTeamMemberProfiles(options) {
67
+ const response = await this.sendServerRequest("/team-member-profiles?team_id=" + options.teamId, {}, null);
68
+ const result = await response.json();
69
+ return result.items;
70
+ }
71
+ async getServerTeamMemberProfile(options) {
72
+ const response = await this.sendServerRequest(`/team-member-profiles/${options.teamId}/${options.userId}`, {}, null);
73
+ return await response.json();
74
+ }
56
75
  async listServerTeamPermissions(options, session) {
57
76
  const response = await this.sendServerRequest("/team-permissions?" + new URLSearchParams(filterUndefined({
58
77
  user_id: options.userId,
@@ -159,10 +178,14 @@ export class StackServerInterface extends StackClientInterface {
159
178
  refreshToken: result.refresh_token,
160
179
  };
161
180
  }
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;
181
+ async leaveServerTeam(options) {
182
+ await this.sendClientRequest(`/team-memberships/${options.teamId}/${options.userId}`, {
183
+ method: "DELETE",
184
+ headers: {
185
+ "content-type": "application/json",
186
+ },
187
+ body: JSON.stringify({}),
188
+ }, null);
166
189
  }
167
190
  async grantServerTeamUserPermission(teamId, userId, permissionId) {
168
191
  await this.sendServerRequest(`/team-permissions/${teamId}/${userId}/${permissionId}`, {
@@ -26,6 +26,7 @@ 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;
@@ -72,6 +73,7 @@ export declare const webhookEvents: readonly [{
72
73
  signed_up_at_millis: undefined;
73
74
  has_password: undefined;
74
75
  auth_with_email: undefined;
76
+ requires_totp_mfa: undefined;
75
77
  oauth_providers: undefined;
76
78
  auth_methods: undefined;
77
79
  connected_accounts: undefined;
@@ -101,6 +103,7 @@ export declare const webhookEvents: readonly [{
101
103
  signed_up_at_millis: number;
102
104
  has_password: NonNullable<boolean | undefined>;
103
105
  auth_with_email: NonNullable<boolean | undefined>;
106
+ requires_totp_mfa: NonNullable<boolean | undefined>;
104
107
  oauth_providers: {
105
108
  email?: string | null | undefined;
106
109
  id: string;
@@ -147,6 +150,7 @@ export declare const webhookEvents: readonly [{
147
150
  signed_up_at_millis: undefined;
148
151
  has_password: undefined;
149
152
  auth_with_email: undefined;
153
+ requires_totp_mfa: undefined;
150
154
  oauth_providers: undefined;
151
155
  auth_methods: undefined;
152
156
  connected_accounts: undefined;
@@ -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
  };
@@ -363,5 +372,8 @@ export declare const KnownErrors: {
363
372
  InvalidAuthorizationCode: KnownErrorConstructor<KnownError & KnownErrorBrand<"INVALID_AUTHORIZATION_CODE">, []> & {
364
373
  errorCode: "INVALID_AUTHORIZATION_CODE";
365
374
  };
375
+ TeamPermissionNotFound: KnownErrorConstructor<KnownError & KnownErrorBrand<"TEAM_PERMISSION_NOT_FOUND">, [any, any, any]> & {
376
+ errorCode: "TEAM_PERMISSION_NOT_FOUND";
377
+ };
366
378
  };
367
379
  export {};