@stackframe/stack-shared 2.7.29 → 2.8.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.8.1
4
+
5
+ ## 2.8.0
6
+
7
+ ### Minor Changes
8
+
9
+ - Various changes
10
+
11
+ ## 2.7.30
12
+
13
+ ### Patch Changes
14
+
15
+ - Various changes
16
+
3
17
  ## 2.7.29
4
18
 
5
19
  ### Patch Changes
@@ -2,6 +2,7 @@ import { InternalSession } from "../sessions";
2
2
  import { ApiKeysCrud } from "./crud/api-keys";
3
3
  import { EmailTemplateCrud, EmailTemplateType } from "./crud/email-templates";
4
4
  import { InternalEmailsCrud } from "./crud/emails";
5
+ import { ProjectPermissionDefinitionsCrud } from "./crud/project-permissions";
5
6
  import { ProjectsCrud } from "./crud/projects";
6
7
  import { SvixTokenCrud } from "./crud/svix-token";
7
8
  import { TeamPermissionDefinitionsCrud } from "./crud/team-permissions";
@@ -41,10 +42,14 @@ export declare class StackAdminInterface extends StackServerInterface {
41
42
  listEmailTemplates(): Promise<EmailTemplateCrud['Admin']['Read'][]>;
42
43
  updateEmailTemplate(type: EmailTemplateType, data: EmailTemplateCrud['Admin']['Update']): Promise<EmailTemplateCrud['Admin']['Read']>;
43
44
  resetEmailTemplate(type: EmailTemplateType): Promise<void>;
44
- listPermissionDefinitions(): Promise<TeamPermissionDefinitionsCrud['Admin']['Read'][]>;
45
- createPermissionDefinition(data: TeamPermissionDefinitionsCrud['Admin']['Create']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']>;
46
- updatePermissionDefinition(permissionId: string, data: TeamPermissionDefinitionsCrud['Admin']['Update']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']>;
47
- deletePermissionDefinition(permissionId: string): Promise<void>;
45
+ listTeamPermissionDefinitions(): Promise<TeamPermissionDefinitionsCrud['Admin']['Read'][]>;
46
+ createTeamPermissionDefinition(data: TeamPermissionDefinitionsCrud['Admin']['Create']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']>;
47
+ updateTeamPermissionDefinition(permissionId: string, data: TeamPermissionDefinitionsCrud['Admin']['Update']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']>;
48
+ deleteTeamPermissionDefinition(permissionId: string): Promise<void>;
49
+ listProjectPermissionDefinitions(): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read'][]>;
50
+ createProjectPermissionDefinition(data: ProjectPermissionDefinitionsCrud['Admin']['Create']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']>;
51
+ updateProjectPermissionDefinition(permissionId: string, data: ProjectPermissionDefinitionsCrud['Admin']['Update']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']>;
52
+ deleteProjectPermissionDefinition(permissionId: string): Promise<void>;
48
53
  getSvixToken(): Promise<SvixTokenCrud["Admin"]["Read"]>;
49
54
  deleteProject(): Promise<void>;
50
55
  getMetrics(): Promise<any>;
@@ -77,12 +77,13 @@ export class StackAdminInterface extends StackServerInterface {
77
77
  async resetEmailTemplate(type) {
78
78
  await this.sendAdminRequest(`/email-templates/${type}`, { method: "DELETE" }, null);
79
79
  }
80
- async listPermissionDefinitions() {
80
+ // Team permission definitions methods
81
+ async listTeamPermissionDefinitions() {
81
82
  const response = await this.sendAdminRequest(`/team-permission-definitions`, {}, null);
82
83
  const result = await response.json();
83
84
  return result.items;
84
85
  }
85
- async createPermissionDefinition(data) {
86
+ async createTeamPermissionDefinition(data) {
86
87
  const response = await this.sendAdminRequest("/team-permission-definitions", {
87
88
  method: "POST",
88
89
  headers: {
@@ -92,7 +93,7 @@ export class StackAdminInterface extends StackServerInterface {
92
93
  }, null);
93
94
  return await response.json();
94
95
  }
95
- async updatePermissionDefinition(permissionId, data) {
96
+ async updateTeamPermissionDefinition(permissionId, data) {
96
97
  const response = await this.sendAdminRequest(`/team-permission-definitions/${permissionId}`, {
97
98
  method: "PATCH",
98
99
  headers: {
@@ -102,9 +103,37 @@ export class StackAdminInterface extends StackServerInterface {
102
103
  }, null);
103
104
  return await response.json();
104
105
  }
105
- async deletePermissionDefinition(permissionId) {
106
+ async deleteTeamPermissionDefinition(permissionId) {
106
107
  await this.sendAdminRequest(`/team-permission-definitions/${permissionId}`, { method: "DELETE" }, null);
107
108
  }
109
+ async listProjectPermissionDefinitions() {
110
+ const response = await this.sendAdminRequest(`/project-permission-definitions`, {}, null);
111
+ const result = await response.json();
112
+ return result.items;
113
+ }
114
+ async createProjectPermissionDefinition(data) {
115
+ const response = await this.sendAdminRequest("/project-permission-definitions", {
116
+ method: "POST",
117
+ headers: {
118
+ "content-type": "application/json",
119
+ },
120
+ body: JSON.stringify(data),
121
+ }, null);
122
+ return await response.json();
123
+ }
124
+ async updateProjectPermissionDefinition(permissionId, data) {
125
+ const response = await this.sendAdminRequest(`/project-permission-definitions/${permissionId}`, {
126
+ method: "PATCH",
127
+ headers: {
128
+ "content-type": "application/json",
129
+ },
130
+ body: JSON.stringify(data),
131
+ }, null);
132
+ return await response.json();
133
+ }
134
+ async deleteProjectPermissionDefinition(permissionId) {
135
+ await this.sendAdminRequest(`/project-permission-definitions/${permissionId}`, { method: "DELETE" }, null);
136
+ }
108
137
  async getSvixToken() {
109
138
  const response = await this.sendAdminRequest("/webhooks/svix-token", {
110
139
  method: "POST",
@@ -10,6 +10,7 @@ import { InternalProjectsCrud, ProjectsCrud } from './crud/projects';
10
10
  import { SessionsCrud } from './crud/sessions';
11
11
  import { TeamInvitationCrud } from './crud/team-invitation';
12
12
  import { TeamMemberProfilesCrud } from './crud/team-member-profiles';
13
+ import { ProjectPermissionsCrud } from './crud/project-permissions';
13
14
  import { TeamPermissionsCrud } from './crud/team-permissions';
14
15
  import { TeamsCrud } from './crud/teams';
15
16
  export type ClientInterfaceOptions = {
@@ -117,6 +118,10 @@ export declare class StackClientInterface {
117
118
  accessToken: string;
118
119
  refreshToken: string;
119
120
  }, KnownErrors["UserWithEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
121
+ signUpAnonymously(session: InternalSession): Promise<Result<{
122
+ accessToken: string;
123
+ refreshToken: string;
124
+ }, never>>;
120
125
  signInWithMagicLink(code: string): Promise<Result<{
121
126
  newUser: boolean;
122
127
  accessToken: string;
@@ -183,6 +188,9 @@ export declare class StackClientInterface {
183
188
  teamId: string;
184
189
  recursive: boolean;
185
190
  }, session: InternalSession): Promise<TeamPermissionsCrud['Client']['Read'][]>;
191
+ listCurrentUserProjectPermissions(options: {
192
+ recursive: boolean;
193
+ }, session: InternalSession): Promise<ProjectPermissionsCrud['Client']['Read'][]>;
186
194
  listCurrentUserTeams(session: InternalSession): Promise<TeamsCrud["Client"]["Read"][]>;
187
195
  getClientProject(): Promise<Result<ProjectsCrud['Client']['Read'], KnownErrors["ProjectNotFound"]>>;
188
196
  updateClientUser(update: CurrentUserCrud["Client"]["Update"], session: InternalSession): Promise<void>;
@@ -576,6 +576,19 @@ export class StackClientInterface {
576
576
  refreshToken: result.refresh_token,
577
577
  });
578
578
  }
579
+ async signUpAnonymously(session) {
580
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/anonymous/sign-up", {
581
+ method: "POST",
582
+ }, session, []);
583
+ if (res.status === "error") {
584
+ return Result.error(res.error);
585
+ }
586
+ const result = await res.data.json();
587
+ return Result.ok({
588
+ accessToken: result.access_token,
589
+ refreshToken: result.refresh_token,
590
+ });
591
+ }
579
592
  async signInWithMagicLink(code) {
580
593
  const res = await this.sendClientRequestAndCatchKnownError("/auth/otp/sign-in", {
581
594
  method: "POST",
@@ -777,6 +790,11 @@ export class StackClientInterface {
777
790
  const result = await response.json();
778
791
  return result.items;
779
792
  }
793
+ async listCurrentUserProjectPermissions(options, session) {
794
+ const response = await this.sendClientRequest(`/project-permissions?user_id=me&recursive=${options.recursive}`, {}, session);
795
+ const result = await response.json();
796
+ return result.items;
797
+ }
780
798
  async listCurrentUserTeams(session) {
781
799
  const response = await this.sendClientRequest("/teams?user_id=me", {}, session);
782
800
  const result = await response.json();
@@ -16,6 +16,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
16
16
  passkey_auth_enabled: boolean;
17
17
  otp_auth_enabled: boolean;
18
18
  selected_team_id: string | null;
19
+ is_anonymous: boolean;
19
20
  signed_up_at_millis: number;
20
21
  has_password: boolean;
21
22
  auth_with_email: boolean;
@@ -51,6 +52,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
51
52
  client_read_only_metadata: undefined;
52
53
  server_metadata: undefined;
53
54
  last_active_at_millis: undefined;
55
+ is_anonymous: undefined;
54
56
  oauth_providers: undefined;
55
57
  auth_with_email: undefined;
56
58
  requires_totp_mfa: undefined;
@@ -80,6 +82,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
80
82
  client_read_only_metadata: {} | null;
81
83
  server_metadata: {} | null;
82
84
  last_active_at_millis: number;
85
+ is_anonymous: boolean;
83
86
  oauth_providers: {
84
87
  email?: string | null | undefined;
85
88
  id: string;
@@ -112,6 +115,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
112
115
  client_read_only_metadata: undefined;
113
116
  server_metadata: undefined;
114
117
  last_active_at_millis: undefined;
118
+ is_anonymous: undefined;
115
119
  oauth_providers: undefined;
116
120
  auth_with_email: undefined;
117
121
  requires_totp_mfa: undefined;
@@ -139,6 +143,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
139
143
  otp_auth_enabled: undefined;
140
144
  totp_secret_base64: undefined;
141
145
  selected_team_id: undefined;
146
+ is_anonymous: undefined;
142
147
  }, "">;
143
148
  serverUpdateSchema: import("yup").ObjectSchema<{
144
149
  display_name: string | null | undefined;
@@ -155,6 +160,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
155
160
  otp_auth_enabled: boolean | undefined;
156
161
  totp_secret_base64: string | null | undefined;
157
162
  selected_team_id: string | null | undefined;
163
+ is_anonymous: boolean | undefined;
158
164
  }, import("yup").AnyObject, {
159
165
  display_name: undefined;
160
166
  profile_image_url: undefined;
@@ -170,6 +176,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
170
176
  otp_auth_enabled: undefined;
171
177
  totp_secret_base64: undefined;
172
178
  selected_team_id: undefined;
179
+ is_anonymous: undefined;
173
180
  }, "">;
174
181
  clientDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
175
182
  docs: {
@@ -28,6 +28,7 @@ const clientReadSchema = usersCrudServerReadSchema.pick([
28
28
  "requires_totp_mfa",
29
29
  "otp_auth_enabled",
30
30
  "passkey_auth_enabled",
31
+ "is_anonymous",
31
32
  ]).concat(yupObject({
32
33
  selected_team: teamsCrudClientReadSchema.nullable().defined(),
33
34
  })).defined();
@@ -0,0 +1,155 @@
1
+ import { CrudTypeOf } from "../../crud";
2
+ export declare const projectPermissionsCrudClientReadSchema: import("yup").ObjectSchema<{
3
+ id: string;
4
+ user_id: string;
5
+ }, import("yup").AnyObject, {
6
+ id: undefined;
7
+ user_id: undefined;
8
+ }, "">;
9
+ export declare const projectPermissionsCrudServerCreateSchema: import("yup").ObjectSchema<{}, import("yup").AnyObject, {}, "">;
10
+ export declare const projectPermissionsCrudServerDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
11
+ export declare const projectPermissionsCrud: import("../../crud").CrudSchemaFromOptions<{
12
+ clientReadSchema: import("yup").ObjectSchema<{
13
+ id: string;
14
+ user_id: string;
15
+ }, import("yup").AnyObject, {
16
+ id: undefined;
17
+ user_id: undefined;
18
+ }, "">;
19
+ serverCreateSchema: import("yup").ObjectSchema<{}, import("yup").AnyObject, {}, "">;
20
+ serverDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
21
+ docs: {
22
+ clientList: {
23
+ summary: string;
24
+ description: string;
25
+ tags: string[];
26
+ };
27
+ serverList: {
28
+ summary: string;
29
+ description: string;
30
+ tags: string[];
31
+ };
32
+ serverCreate: {
33
+ summary: string;
34
+ description: string;
35
+ tags: string[];
36
+ };
37
+ serverDelete: {
38
+ summary: string;
39
+ description: string;
40
+ tags: string[];
41
+ };
42
+ };
43
+ }>;
44
+ export type ProjectPermissionsCrud = CrudTypeOf<typeof projectPermissionsCrud>;
45
+ export declare const projectPermissionCreatedWebhookEvent: {
46
+ type: string;
47
+ schema: import("yup").ObjectSchema<{
48
+ id: string;
49
+ user_id: string;
50
+ }, import("yup").AnyObject, {
51
+ id: undefined;
52
+ user_id: undefined;
53
+ }, "">;
54
+ metadata: {
55
+ summary: string;
56
+ description: string;
57
+ tags: string[];
58
+ };
59
+ };
60
+ export declare const projectPermissionDeletedWebhookEvent: {
61
+ type: string;
62
+ schema: import("yup").ObjectSchema<{
63
+ id: string;
64
+ user_id: string;
65
+ }, import("yup").AnyObject, {
66
+ id: undefined;
67
+ user_id: undefined;
68
+ }, "">;
69
+ metadata: {
70
+ summary: string;
71
+ description: string;
72
+ tags: string[];
73
+ };
74
+ };
75
+ export declare const projectPermissionDefinitionsCrudAdminReadSchema: import("yup").ObjectSchema<{
76
+ id: string;
77
+ description: string | undefined;
78
+ contained_permission_ids: string[];
79
+ }, import("yup").AnyObject, {
80
+ id: undefined;
81
+ description: undefined;
82
+ contained_permission_ids: undefined;
83
+ }, "">;
84
+ export declare const projectPermissionDefinitionsCrudAdminCreateSchema: import("yup").ObjectSchema<{
85
+ id: string;
86
+ description: string | undefined;
87
+ contained_permission_ids: string[] | undefined;
88
+ }, import("yup").AnyObject, {
89
+ id: undefined;
90
+ description: undefined;
91
+ contained_permission_ids: undefined;
92
+ }, "">;
93
+ export declare const projectPermissionDefinitionsCrudAdminUpdateSchema: import("yup").ObjectSchema<{
94
+ id: string | undefined;
95
+ description: string | undefined;
96
+ contained_permission_ids: string[] | undefined;
97
+ }, import("yup").AnyObject, {
98
+ id: undefined;
99
+ description: undefined;
100
+ contained_permission_ids: undefined;
101
+ }, "">;
102
+ export declare const projectPermissionDefinitionsCrudAdminDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
103
+ export declare const projectPermissionDefinitionsCrud: import("../../crud").CrudSchemaFromOptions<{
104
+ adminReadSchema: import("yup").ObjectSchema<{
105
+ id: string;
106
+ description: string | undefined;
107
+ contained_permission_ids: string[];
108
+ }, import("yup").AnyObject, {
109
+ id: undefined;
110
+ description: undefined;
111
+ contained_permission_ids: undefined;
112
+ }, "">;
113
+ adminCreateSchema: import("yup").ObjectSchema<{
114
+ id: string;
115
+ description: string | undefined;
116
+ contained_permission_ids: string[] | undefined;
117
+ }, import("yup").AnyObject, {
118
+ id: undefined;
119
+ description: undefined;
120
+ contained_permission_ids: undefined;
121
+ }, "">;
122
+ adminUpdateSchema: import("yup").ObjectSchema<{
123
+ id: string | undefined;
124
+ description: string | undefined;
125
+ contained_permission_ids: string[] | undefined;
126
+ }, import("yup").AnyObject, {
127
+ id: undefined;
128
+ description: undefined;
129
+ contained_permission_ids: undefined;
130
+ }, "">;
131
+ adminDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
132
+ docs: {
133
+ adminList: {
134
+ summary: string;
135
+ description: string;
136
+ tags: string[];
137
+ };
138
+ adminCreate: {
139
+ summary: string;
140
+ description: string;
141
+ tags: string[];
142
+ };
143
+ adminUpdate: {
144
+ summary: string;
145
+ description: string;
146
+ tags: string[];
147
+ };
148
+ adminDelete: {
149
+ summary: string;
150
+ description: string;
151
+ tags: string[];
152
+ };
153
+ };
154
+ }>;
155
+ export type ProjectPermissionDefinitionsCrud = CrudTypeOf<typeof projectPermissionDefinitionsCrud>;
@@ -0,0 +1,100 @@
1
+ import { createCrud } from "../../crud";
2
+ import * as schemaFields from "../../schema-fields";
3
+ import { yupMixed, yupObject } from "../../schema-fields";
4
+ // =============== Project permissions =================
5
+ export const projectPermissionsCrudClientReadSchema = yupObject({
6
+ id: schemaFields.permissionDefinitionIdSchema.defined(),
7
+ user_id: schemaFields.userIdSchema.defined(),
8
+ }).defined();
9
+ export const projectPermissionsCrudServerCreateSchema = yupObject({}).defined();
10
+ export const projectPermissionsCrudServerDeleteSchema = yupMixed();
11
+ export const projectPermissionsCrud = createCrud({
12
+ clientReadSchema: projectPermissionsCrudClientReadSchema,
13
+ serverCreateSchema: projectPermissionsCrudServerCreateSchema,
14
+ serverDeleteSchema: projectPermissionsCrudServerDeleteSchema,
15
+ docs: {
16
+ clientList: {
17
+ summary: "List project permissions",
18
+ description: "List global permissions of the current user. `user_id=me` must be set for client requests. `(user_id, permission_id)` together uniquely identify a permission.",
19
+ tags: ["Permissions"],
20
+ },
21
+ serverList: {
22
+ summary: "List project permissions",
23
+ description: "Query and filter the permission with `user_id` and `permission_id`. `(user_id, permission_id)` together uniquely identify a permission.",
24
+ tags: ["Permissions"],
25
+ },
26
+ serverCreate: {
27
+ summary: "Grant a global permission to a user",
28
+ description: "Grant a global permission to a user (the permission must be created first on the Stack dashboard)",
29
+ tags: ["Permissions"],
30
+ },
31
+ serverDelete: {
32
+ summary: "Revoke a global permission from a user",
33
+ description: "Revoke a global permission from a user",
34
+ tags: ["Permissions"],
35
+ },
36
+ },
37
+ });
38
+ export const projectPermissionCreatedWebhookEvent = {
39
+ type: "project_permission.created",
40
+ schema: projectPermissionsCrud.server.readSchema,
41
+ metadata: {
42
+ summary: "Project Permission Created",
43
+ description: "This event is triggered when a project permission is created.",
44
+ tags: ["Users"],
45
+ },
46
+ };
47
+ export const projectPermissionDeletedWebhookEvent = {
48
+ type: "project_permission.deleted",
49
+ schema: projectPermissionsCrud.server.readSchema,
50
+ metadata: {
51
+ summary: "Project Permission Deleted",
52
+ description: "This event is triggered when a project permission is deleted.",
53
+ tags: ["Users"],
54
+ },
55
+ };
56
+ // =============== Project permission definitions =================
57
+ export const projectPermissionDefinitionsCrudAdminReadSchema = yupObject({
58
+ id: schemaFields.permissionDefinitionIdSchema.defined(),
59
+ description: schemaFields.teamPermissionDescriptionSchema.optional(),
60
+ contained_permission_ids: schemaFields.containedPermissionIdsSchema.defined(),
61
+ }).defined();
62
+ export const projectPermissionDefinitionsCrudAdminCreateSchema = yupObject({
63
+ id: schemaFields.customPermissionDefinitionIdSchema.defined(),
64
+ description: schemaFields.teamPermissionDescriptionSchema.optional(),
65
+ contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional(),
66
+ }).defined();
67
+ export const projectPermissionDefinitionsCrudAdminUpdateSchema = yupObject({
68
+ id: schemaFields.customPermissionDefinitionIdSchema.optional(),
69
+ description: schemaFields.teamPermissionDescriptionSchema.optional(),
70
+ contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional(),
71
+ }).defined();
72
+ export const projectPermissionDefinitionsCrudAdminDeleteSchema = yupMixed();
73
+ export const projectPermissionDefinitionsCrud = createCrud({
74
+ adminReadSchema: projectPermissionDefinitionsCrudAdminReadSchema,
75
+ adminCreateSchema: projectPermissionDefinitionsCrudAdminCreateSchema,
76
+ adminUpdateSchema: projectPermissionDefinitionsCrudAdminUpdateSchema,
77
+ adminDeleteSchema: projectPermissionDefinitionsCrudAdminDeleteSchema,
78
+ docs: {
79
+ adminList: {
80
+ summary: "List project permission definitions",
81
+ description: "Query and filter project permission definitions (the equivalent of listing permissions on the Stack dashboard)",
82
+ tags: ["Permissions"],
83
+ },
84
+ adminCreate: {
85
+ summary: "Create a new project permission definition",
86
+ description: "Create a new project permission definition (the equivalent of creating a new permission on the Stack dashboard)",
87
+ tags: ["Permissions"],
88
+ },
89
+ adminUpdate: {
90
+ summary: "Update a project permission definition",
91
+ description: "Update a project permission definition (the equivalent of updating a permission on the Stack dashboard)",
92
+ tags: ["Permissions"],
93
+ },
94
+ adminDelete: {
95
+ summary: "Delete a project permission definition",
96
+ description: "Delete a project permission definition (the equivalent of deleting a permission on the Stack dashboard)",
97
+ tags: ["Permissions"],
98
+ },
99
+ },
100
+ });
@@ -80,6 +80,9 @@ export declare const projectsCrudAdminReadSchema: import("yup").ObjectSchema<{
80
80
  team_member_default_permissions: {
81
81
  id: string;
82
82
  }[];
83
+ user_default_permissions: {
84
+ id: string;
85
+ }[];
83
86
  oauth_account_merge_strategy: "link_method" | "raise_error" | "allow_duplicates";
84
87
  };
85
88
  }, import("yup").AnyObject, {
@@ -113,6 +116,7 @@ export declare const projectsCrudAdminReadSchema: import("yup").ObjectSchema<{
113
116
  create_team_on_sign_up: undefined;
114
117
  team_creator_default_permissions: undefined;
115
118
  team_member_default_permissions: undefined;
119
+ user_default_permissions: undefined;
116
120
  oauth_account_merge_strategy: undefined;
117
121
  };
118
122
  }, "">;
@@ -184,6 +188,9 @@ export declare const projectsCrudAdminUpdateSchema: import("yup").ObjectSchema<{
184
188
  team_member_default_permissions?: {
185
189
  id: string;
186
190
  }[] | undefined;
191
+ user_default_permissions?: {
192
+ id: string;
193
+ }[] | undefined;
187
194
  oauth_account_merge_strategy?: "link_method" | "raise_error" | "allow_duplicates" | undefined;
188
195
  } | undefined;
189
196
  }, import("yup").AnyObject, {
@@ -233,6 +240,9 @@ export declare const projectsCrudAdminCreateSchema: import("yup").ObjectSchema<{
233
240
  team_member_default_permissions?: {
234
241
  id: string;
235
242
  }[] | undefined;
243
+ user_default_permissions?: {
244
+ id: string;
245
+ }[] | undefined;
236
246
  oauth_account_merge_strategy?: "link_method" | "raise_error" | "allow_duplicates" | undefined;
237
247
  } | undefined;
238
248
  } & {
@@ -320,6 +330,9 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
320
330
  team_member_default_permissions: {
321
331
  id: string;
322
332
  }[];
333
+ user_default_permissions: {
334
+ id: string;
335
+ }[];
323
336
  oauth_account_merge_strategy: "link_method" | "raise_error" | "allow_duplicates";
324
337
  };
325
338
  }, import("yup").AnyObject, {
@@ -353,6 +366,7 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
353
366
  create_team_on_sign_up: undefined;
354
367
  team_creator_default_permissions: undefined;
355
368
  team_member_default_permissions: undefined;
369
+ user_default_permissions: undefined;
356
370
  oauth_account_merge_strategy: undefined;
357
371
  };
358
372
  }, "">;
@@ -397,6 +411,9 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
397
411
  team_member_default_permissions?: {
398
412
  id: string;
399
413
  }[] | undefined;
414
+ user_default_permissions?: {
415
+ id: string;
416
+ }[] | undefined;
400
417
  oauth_account_merge_strategy?: "link_method" | "raise_error" | "allow_duplicates" | undefined;
401
418
  } | undefined;
402
419
  }, import("yup").AnyObject, {
@@ -479,6 +496,9 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
479
496
  team_member_default_permissions: {
480
497
  id: string;
481
498
  }[];
499
+ user_default_permissions: {
500
+ id: string;
501
+ }[];
482
502
  oauth_account_merge_strategy: "link_method" | "raise_error" | "allow_duplicates";
483
503
  };
484
504
  }, import("yup").AnyObject, {
@@ -512,6 +532,7 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
512
532
  create_team_on_sign_up: undefined;
513
533
  team_creator_default_permissions: undefined;
514
534
  team_member_default_permissions: undefined;
535
+ user_default_permissions: undefined;
515
536
  oauth_account_merge_strategy: undefined;
516
537
  };
517
538
  }, "">;
@@ -556,6 +577,9 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
556
577
  team_member_default_permissions?: {
557
578
  id: string;
558
579
  }[] | undefined;
580
+ user_default_permissions?: {
581
+ id: string;
582
+ }[] | undefined;
559
583
  oauth_account_merge_strategy?: "link_method" | "raise_error" | "allow_duplicates" | undefined;
560
584
  } | undefined;
561
585
  } & {
@@ -75,6 +75,7 @@ export const projectsCrudAdminReadSchema = yupObject({
75
75
  create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.defined(),
76
76
  team_creator_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),
77
77
  team_member_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),
78
+ user_default_permissions: yupArray(teamPermissionSchema.defined()).defined(),
78
79
  oauth_account_merge_strategy: schemaFields.oauthAccountMergeStrategySchema.defined(),
79
80
  }).defined(),
80
81
  }).defined();
@@ -109,6 +110,7 @@ export const projectsCrudAdminUpdateSchema = yupObject({
109
110
  create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.optional(),
110
111
  team_creator_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),
111
112
  team_member_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),
113
+ user_default_permissions: yupArray(teamPermissionSchema.defined()).optional(),
112
114
  oauth_account_merge_strategy: schemaFields.oauthAccountMergeStrategySchema.optional(),
113
115
  }).optional().default(undefined),
114
116
  }).defined();
@@ -29,6 +29,16 @@ export declare const teamInvitationCrud: import("../../crud").CrudSchemaFromOpti
29
29
  description: string;
30
30
  tags: string[];
31
31
  };
32
+ clientList: {
33
+ summary: string;
34
+ description: string;
35
+ tags: string[];
36
+ };
37
+ clientDelete: {
38
+ summary: string;
39
+ description: string;
40
+ tags: string[];
41
+ };
32
42
  };
33
43
  }>;
34
44
  export type TeamInvitationCrud = CrudTypeOf<typeof teamInvitationCrud>;
@@ -16,5 +16,15 @@ export const teamInvitationCrud = createCrud({
16
16
  description: "",
17
17
  tags: ["Teams"],
18
18
  },
19
+ clientList: {
20
+ summary: "List team invitations",
21
+ description: "",
22
+ tags: ["Teams"],
23
+ },
24
+ clientDelete: {
25
+ summary: "Delete a team invitation",
26
+ description: "",
27
+ tags: ["Teams"],
28
+ },
19
29
  },
20
30
  });
@@ -34,6 +34,7 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
34
34
  passkey_auth_enabled: boolean;
35
35
  otp_auth_enabled: boolean;
36
36
  selected_team_id: string | null;
37
+ is_anonymous: boolean;
37
38
  selected_team: {
38
39
  client_metadata?: {} | null | undefined;
39
40
  client_read_only_metadata?: {} | null | undefined;
@@ -79,6 +80,7 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
79
80
  client_read_only_metadata: undefined;
80
81
  server_metadata: undefined;
81
82
  last_active_at_millis: undefined;
83
+ is_anonymous: undefined;
82
84
  oauth_providers: undefined;
83
85
  auth_with_email: undefined;
84
86
  requires_totp_mfa: undefined;
@@ -127,6 +129,7 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
127
129
  passkey_auth_enabled: boolean;
128
130
  otp_auth_enabled: boolean;
129
131
  selected_team_id: string | null;
132
+ is_anonymous: boolean;
130
133
  selected_team: {
131
134
  client_metadata?: {} | null | undefined;
132
135
  client_read_only_metadata?: {} | null | undefined;
@@ -172,6 +175,7 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
172
175
  client_read_only_metadata: undefined;
173
176
  server_metadata: undefined;
174
177
  last_active_at_millis: undefined;
178
+ is_anonymous: undefined;
175
179
  oauth_providers: undefined;
176
180
  auth_with_email: undefined;
177
181
  requires_totp_mfa: undefined;
@@ -3,7 +3,7 @@ import * as schemaFields from "../../schema-fields";
3
3
  import { yupMixed, yupObject } from "../../schema-fields";
4
4
  // =============== Team permissions =================
5
5
  export const teamPermissionsCrudClientReadSchema = yupObject({
6
- id: schemaFields.teamPermissionDefinitionIdSchema.defined(),
6
+ id: schemaFields.permissionDefinitionIdSchema.defined(),
7
7
  user_id: schemaFields.userIdSchema.defined(),
8
8
  team_id: schemaFields.teamIdSchema.defined(),
9
9
  }).defined();
@@ -56,19 +56,19 @@ export const teamPermissionDeletedWebhookEvent = {
56
56
  };
57
57
  // =============== Team permission definitions =================
58
58
  export const teamPermissionDefinitionsCrudAdminReadSchema = yupObject({
59
- id: schemaFields.teamPermissionDefinitionIdSchema.defined(),
59
+ id: schemaFields.permissionDefinitionIdSchema.defined(),
60
60
  description: schemaFields.teamPermissionDescriptionSchema.optional(),
61
- contained_permission_ids: schemaFields.containedPermissionIdsSchema.defined()
61
+ contained_permission_ids: schemaFields.containedPermissionIdsSchema.defined(),
62
62
  }).defined();
63
63
  export const teamPermissionDefinitionsCrudAdminCreateSchema = yupObject({
64
- id: schemaFields.customTeamPermissionDefinitionIdSchema.defined(),
64
+ id: schemaFields.customPermissionDefinitionIdSchema.defined(),
65
65
  description: schemaFields.teamPermissionDescriptionSchema.optional(),
66
- contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional()
66
+ contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional(),
67
67
  }).defined();
68
68
  export const teamPermissionDefinitionsCrudAdminUpdateSchema = yupObject({
69
- id: schemaFields.customTeamPermissionDefinitionIdSchema.optional(),
69
+ id: schemaFields.customPermissionDefinitionIdSchema.optional(),
70
70
  description: schemaFields.teamPermissionDescriptionSchema.optional(),
71
- contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional()
71
+ contained_permission_ids: schemaFields.containedPermissionIdsSchema.optional(),
72
72
  }).defined();
73
73
  export const teamPermissionDefinitionsCrudAdminDeleteSchema = yupMixed();
74
74
  export const teamPermissionDefinitionsCrud = createCrud({
@@ -14,6 +14,7 @@ export declare const usersCrudServerUpdateSchema: import("yup").ObjectSchema<{
14
14
  otp_auth_enabled: boolean | undefined;
15
15
  totp_secret_base64: string | null | undefined;
16
16
  selected_team_id: string | null | undefined;
17
+ is_anonymous: boolean | undefined;
17
18
  }, import("yup").AnyObject, {
18
19
  display_name: undefined;
19
20
  profile_image_url: undefined;
@@ -29,6 +30,7 @@ export declare const usersCrudServerUpdateSchema: import("yup").ObjectSchema<{
29
30
  otp_auth_enabled: undefined;
30
31
  totp_secret_base64: undefined;
31
32
  selected_team_id: undefined;
33
+ is_anonymous: undefined;
32
34
  }, "">;
33
35
  export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
34
36
  id: string;
@@ -55,6 +57,7 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
55
57
  client_read_only_metadata: {} | null;
56
58
  server_metadata: {} | null;
57
59
  last_active_at_millis: number;
60
+ is_anonymous: boolean;
58
61
  oauth_providers: {
59
62
  email?: string | null | undefined;
60
63
  id: string;
@@ -87,6 +90,7 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
87
90
  client_read_only_metadata: undefined;
88
91
  server_metadata: undefined;
89
92
  last_active_at_millis: undefined;
93
+ is_anonymous: undefined;
90
94
  oauth_providers: undefined;
91
95
  auth_with_email: undefined;
92
96
  requires_totp_mfa: undefined;
@@ -105,12 +109,14 @@ export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
105
109
  password_hash: string | undefined;
106
110
  otp_auth_enabled: boolean | undefined;
107
111
  totp_secret_base64: string | null | undefined;
112
+ is_anonymous: boolean | undefined;
108
113
  } & {
109
114
  oauth_providers: {
110
115
  email: string | null;
111
116
  id: string;
112
117
  account_id: string;
113
118
  }[] | undefined;
119
+ is_anonymous: boolean | undefined;
114
120
  }, import("yup").AnyObject, {
115
121
  display_name: undefined;
116
122
  profile_image_url: undefined;
@@ -126,6 +132,7 @@ export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
126
132
  otp_auth_enabled: undefined;
127
133
  totp_secret_base64: undefined;
128
134
  selected_team_id: undefined;
135
+ is_anonymous: undefined;
129
136
  oauth_providers: undefined;
130
137
  }, "">;
131
138
  export declare const usersCrudServerDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
@@ -155,6 +162,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
155
162
  client_read_only_metadata: {} | null;
156
163
  server_metadata: {} | null;
157
164
  last_active_at_millis: number;
165
+ is_anonymous: boolean;
158
166
  oauth_providers: {
159
167
  email?: string | null | undefined;
160
168
  id: string;
@@ -187,6 +195,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
187
195
  client_read_only_metadata: undefined;
188
196
  server_metadata: undefined;
189
197
  last_active_at_millis: undefined;
198
+ is_anonymous: undefined;
190
199
  oauth_providers: undefined;
191
200
  auth_with_email: undefined;
192
201
  requires_totp_mfa: undefined;
@@ -206,6 +215,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
206
215
  otp_auth_enabled: boolean | undefined;
207
216
  totp_secret_base64: string | null | undefined;
208
217
  selected_team_id: string | null | undefined;
218
+ is_anonymous: boolean | undefined;
209
219
  }, import("yup").AnyObject, {
210
220
  display_name: undefined;
211
221
  profile_image_url: undefined;
@@ -221,6 +231,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
221
231
  otp_auth_enabled: undefined;
222
232
  totp_secret_base64: undefined;
223
233
  selected_team_id: undefined;
234
+ is_anonymous: undefined;
224
235
  }, "">;
225
236
  serverCreateSchema: import("yup").ObjectSchema<{
226
237
  primary_email: string | null | undefined;
@@ -236,12 +247,14 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
236
247
  password_hash: string | undefined;
237
248
  otp_auth_enabled: boolean | undefined;
238
249
  totp_secret_base64: string | null | undefined;
250
+ is_anonymous: boolean | undefined;
239
251
  } & {
240
252
  oauth_providers: {
241
253
  email: string | null;
242
254
  id: string;
243
255
  account_id: string;
244
256
  }[] | undefined;
257
+ is_anonymous: boolean | undefined;
245
258
  }, import("yup").AnyObject, {
246
259
  display_name: undefined;
247
260
  profile_image_url: undefined;
@@ -257,6 +270,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
257
270
  otp_auth_enabled: undefined;
258
271
  totp_secret_base64: undefined;
259
272
  selected_team_id: undefined;
273
+ is_anonymous: undefined;
260
274
  oauth_providers: undefined;
261
275
  }, "">;
262
276
  serverDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
@@ -316,6 +330,7 @@ export declare const userCreatedWebhookEvent: {
316
330
  client_read_only_metadata: {} | null;
317
331
  server_metadata: {} | null;
318
332
  last_active_at_millis: number;
333
+ is_anonymous: boolean;
319
334
  oauth_providers: {
320
335
  email?: string | null | undefined;
321
336
  id: string;
@@ -348,6 +363,7 @@ export declare const userCreatedWebhookEvent: {
348
363
  client_read_only_metadata: undefined;
349
364
  server_metadata: undefined;
350
365
  last_active_at_millis: undefined;
366
+ is_anonymous: undefined;
351
367
  oauth_providers: undefined;
352
368
  auth_with_email: undefined;
353
369
  requires_totp_mfa: undefined;
@@ -385,6 +401,7 @@ export declare const userUpdatedWebhookEvent: {
385
401
  client_read_only_metadata: {} | null;
386
402
  server_metadata: {} | null;
387
403
  last_active_at_millis: number;
404
+ is_anonymous: boolean;
388
405
  oauth_providers: {
389
406
  email?: string | null | undefined;
390
407
  id: string;
@@ -417,6 +434,7 @@ export declare const userUpdatedWebhookEvent: {
417
434
  client_read_only_metadata: undefined;
418
435
  server_metadata: undefined;
419
436
  last_active_at_millis: undefined;
437
+ is_anonymous: undefined;
420
438
  oauth_providers: undefined;
421
439
  auth_with_email: undefined;
422
440
  requires_totp_mfa: undefined;
@@ -16,6 +16,7 @@ export const usersCrudServerUpdateSchema = fieldSchema.yupObject({
16
16
  otp_auth_enabled: fieldSchema.userOtpAuthEnabledMutationSchema.optional(),
17
17
  totp_secret_base64: fieldSchema.userTotpSecretMutationSchema.optional(),
18
18
  selected_team_id: fieldSchema.selectedTeamIdSchema.nullable().optional(),
19
+ is_anonymous: fieldSchema.yupBoolean().oneOf([false]).optional(),
19
20
  }).defined();
20
21
  export const usersCrudServerReadSchema = fieldSchema.yupObject({
21
22
  id: fieldSchema.userIdSchema.defined(),
@@ -34,6 +35,7 @@ export const usersCrudServerReadSchema = fieldSchema.yupObject({
34
35
  client_read_only_metadata: fieldSchema.userClientReadOnlyMetadataSchema,
35
36
  server_metadata: fieldSchema.userServerMetadataSchema,
36
37
  last_active_at_millis: fieldSchema.userLastActiveAtMillisSchema.nonNullable().defined(),
38
+ is_anonymous: fieldSchema.yupBoolean().defined(),
37
39
  oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({
38
40
  id: fieldSchema.yupString().defined(),
39
41
  account_id: fieldSchema.yupString().defined(),
@@ -54,6 +56,7 @@ export const usersCrudServerCreateSchema = usersCrudServerUpdateSchema.omit(['se
54
56
  account_id: fieldSchema.yupString().defined(),
55
57
  email: fieldSchema.yupString().nullable().defined().default(null),
56
58
  }).defined()).optional().meta({ openapiField: { hidden: true } }),
59
+ is_anonymous: fieldSchema.yupBoolean().optional(),
57
60
  }).defined());
58
61
  export const usersCrudServerDeleteSchema = fieldSchema.yupMixed();
59
62
  export const usersCrud = createCrud({
@@ -9,6 +9,7 @@ import { SessionsCrud } from "./crud/sessions";
9
9
  import { TeamInvitationCrud } from "./crud/team-invitation";
10
10
  import { TeamMemberProfilesCrud } from "./crud/team-member-profiles";
11
11
  import { TeamMembershipsCrud } from "./crud/team-memberships";
12
+ import { ProjectPermissionsCrud } from "./crud/project-permissions";
12
13
  import { TeamPermissionsCrud } from "./crud/team-permissions";
13
14
  import { TeamsCrud } from "./crud/teams";
14
15
  import { UsersCrud } from "./crud/users";
@@ -51,6 +52,10 @@ export declare class StackServerInterface extends StackClientInterface {
51
52
  teamId?: string;
52
53
  recursive: boolean;
53
54
  }, session: InternalSession | null): Promise<TeamPermissionsCrud['Server']['Read'][]>;
55
+ listServerProjectPermissions(options: {
56
+ userId?: string;
57
+ recursive: boolean;
58
+ }, session: InternalSession | null): Promise<ProjectPermissionsCrud['Server']['Read'][]>;
54
59
  listServerUsers(options: {
55
60
  cursor?: string;
56
61
  limit?: number;
@@ -91,6 +91,14 @@ export class StackServerInterface extends StackClientInterface {
91
91
  const result = await response.json();
92
92
  return result.items;
93
93
  }
94
+ async listServerProjectPermissions(options, session) {
95
+ const response = await this.sendServerRequest(`/project-permissions?${new URLSearchParams(filterUndefined({
96
+ user_id: options.userId,
97
+ recursive: options.recursive.toString(),
98
+ }))}`, {}, session);
99
+ const result = await response.json();
100
+ return result.items;
101
+ }
94
102
  async listServerUsers(options) {
95
103
  const searchParams = new URLSearchParams(filterUndefined({
96
104
  cursor: options.cursor,
@@ -35,6 +35,7 @@ export declare const webhookEvents: readonly [{
35
35
  client_read_only_metadata: {} | null;
36
36
  server_metadata: {} | null;
37
37
  last_active_at_millis: number;
38
+ is_anonymous: boolean;
38
39
  oauth_providers: {
39
40
  email?: string | null | undefined;
40
41
  id: string;
@@ -67,6 +68,7 @@ export declare const webhookEvents: readonly [{
67
68
  client_read_only_metadata: undefined;
68
69
  server_metadata: undefined;
69
70
  last_active_at_millis: undefined;
71
+ is_anonymous: undefined;
70
72
  oauth_providers: undefined;
71
73
  auth_with_email: undefined;
72
74
  requires_totp_mfa: undefined;
@@ -103,6 +105,7 @@ export declare const webhookEvents: readonly [{
103
105
  client_read_only_metadata: {} | null;
104
106
  server_metadata: {} | null;
105
107
  last_active_at_millis: number;
108
+ is_anonymous: boolean;
106
109
  oauth_providers: {
107
110
  email?: string | null | undefined;
108
111
  id: string;
@@ -135,6 +138,7 @@ export declare const webhookEvents: readonly [{
135
138
  client_read_only_metadata: undefined;
136
139
  server_metadata: undefined;
137
140
  last_active_at_millis: undefined;
141
+ is_anonymous: undefined;
138
142
  oauth_providers: undefined;
139
143
  auth_with_email: undefined;
140
144
  requires_totp_mfa: undefined;
@@ -247,6 +247,9 @@ export declare const KnownErrors: {
247
247
  PasskeyAuthenticationNotEnabled: KnownErrorConstructor<KnownError & KnownErrorBrand<"PASSKEY_AUTHENTICATION_NOT_ENABLED">, []> & {
248
248
  errorCode: "PASSKEY_AUTHENTICATION_NOT_ENABLED";
249
249
  };
250
+ AnonymousAccountsNotEnabled: KnownErrorConstructor<KnownError & KnownErrorBrand<"ANONYMOUS_ACCOUNTS_NOT_ENABLED">, []> & {
251
+ errorCode: "ANONYMOUS_ACCOUNTS_NOT_ENABLED";
252
+ };
250
253
  EmailPasswordMismatch: KnownErrorConstructor<KnownError & KnownErrorBrand<"EMAIL_PASSWORD_MISMATCH">, []> & {
251
254
  errorCode: "EMAIL_PASSWORD_MISMATCH";
252
255
  };
@@ -370,6 +373,9 @@ export declare const KnownErrors: {
370
373
  TeamMembershipAlreadyExists: KnownErrorConstructor<KnownError & KnownErrorBrand<"TEAM_MEMBERSHIP_ALREADY_EXISTS">, []> & {
371
374
  errorCode: "TEAM_MEMBERSHIP_ALREADY_EXISTS";
372
375
  };
376
+ ProjectPermissionRequired: KnownErrorConstructor<KnownError & KnownErrorBrand<"PROJECT_PERMISSION_REQUIRED">, [any, any]> & {
377
+ errorCode: "PROJECT_PERMISSION_REQUIRED";
378
+ };
373
379
  TeamPermissionRequired: KnownErrorConstructor<KnownError & KnownErrorBrand<"TEAM_PERMISSION_REQUIRED">, [any, any, any]> & {
374
380
  errorCode: "TEAM_PERMISSION_REQUIRED";
375
381
  };
@@ -320,6 +320,10 @@ const PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError,
320
320
  400,
321
321
  "Passkey authentication is not enabled for this project.",
322
322
  ], () => []);
323
+ const AnonymousAccountsNotEnabled = createKnownErrorConstructor(KnownError, "ANONYMOUS_ACCOUNTS_NOT_ENABLED", () => [
324
+ 400,
325
+ "Anonymous accounts are not enabled for this project.",
326
+ ], () => []);
323
327
  const EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [
324
328
  400,
325
329
  "Wrong e-mail or password.",
@@ -506,6 +510,14 @@ const TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEA
506
510
  409,
507
511
  "Team membership already exists.",
508
512
  ], () => []);
513
+ const ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
514
+ 401,
515
+ `User ${userId} does not have permission ${permissionId}.`,
516
+ {
517
+ user_id: userId,
518
+ permission_id: permissionId,
519
+ },
520
+ ], (json) => [json.user_id, json.permission_id]);
509
521
  const TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
510
522
  401,
511
523
  `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
@@ -606,6 +618,7 @@ export const KnownErrors = {
606
618
  SignUpNotEnabled,
607
619
  PasswordAuthenticationNotEnabled,
608
620
  PasskeyAuthenticationNotEnabled,
621
+ AnonymousAccountsNotEnabled,
609
622
  EmailPasswordMismatch,
610
623
  RedirectUrlNotWhitelisted,
611
624
  PasswordRequirementsNotMet,
@@ -643,6 +656,7 @@ export const KnownErrors = {
643
656
  InvalidTotpCode,
644
657
  UserAuthenticationRequired,
645
658
  TeamMembershipAlreadyExists,
659
+ ProjectPermissionRequired,
646
660
  TeamPermissionRequired,
647
661
  InvalidSharedOAuthProviderId,
648
662
  InvalidStandardOAuthProviderId,
@@ -131,8 +131,8 @@ export declare const signInResponseSchema: yup.ObjectSchema<{
131
131
  user_id: undefined;
132
132
  }, "">;
133
133
  export declare const teamSystemPermissions: readonly ["$update_team", "$delete_team", "$read_members", "$remove_members", "$invite_members"];
134
- export declare const teamPermissionDefinitionIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
135
- export declare const customTeamPermissionDefinitionIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
134
+ export declare const permissionDefinitionIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
135
+ export declare const customPermissionDefinitionIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
136
136
  export declare const teamPermissionDescriptionSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
137
137
  export declare const containedPermissionIdsSchema: yup.ArraySchema<string[] | undefined, yup.AnyObject, undefined, "">;
138
138
  export declare const teamIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
@@ -327,7 +327,7 @@ export const teamSystemPermissions = [
327
327
  '$remove_members',
328
328
  '$invite_members',
329
329
  ];
330
- export const teamPermissionDefinitionIdSchema = yupString()
330
+ export const permissionDefinitionIdSchema = yupString()
331
331
  .matches(/^\$?[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" and optional "$" at the beginning are allowed')
332
332
  .test('is-system-permission', 'System permissions must start with a dollar sign', (value, ctx) => {
333
333
  if (!value)
@@ -338,11 +338,11 @@ export const teamPermissionDefinitionIdSchema = yupString()
338
338
  return true;
339
339
  })
340
340
  .meta({ openapiField: { description: `The permission ID used to uniquely identify a permission. Can either be a custom permission with lowercase letters, numbers, \`:\`, and \`_\` characters, or one of the system permissions: ${teamSystemPermissions.map(x => `\`${x}\``).join(', ')}`, exampleValue: 'read_secret_info' } });
341
- export const customTeamPermissionDefinitionIdSchema = yupString()
341
+ export const customPermissionDefinitionIdSchema = yupString()
342
342
  .matches(/^[a-z0-9_:]+$/, 'Only lowercase letters, numbers, ":", "_" are allowed')
343
343
  .meta({ openapiField: { description: 'The permission ID used to uniquely identify a permission. Can only contain lowercase letters, numbers, ":", and "_" characters', exampleValue: 'read_secret_info' } });
344
344
  export const teamPermissionDescriptionSchema = yupString().meta({ openapiField: { description: 'A human-readable description of the permission', exampleValue: 'Read secret information' } });
345
- export const containedPermissionIdsSchema = yupArray(teamPermissionDefinitionIdSchema.defined()).meta({ openapiField: { description: 'The IDs of the permissions that are contained in this permission', exampleValue: ['read_public_info'] } });
345
+ export const containedPermissionIdsSchema = yupArray(permissionDefinitionIdSchema.defined()).meta({ openapiField: { description: 'The IDs of the permissions that are contained in this permission', exampleValue: ['read_public_info'] } });
346
346
  // Teams
347
347
  export const teamIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription('team'), exampleValue: 'ad962777-8244-496a-b6a2-e0c6a449c79e' } });
348
348
  export const teamDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription('team'), exampleValue: 'My Team' } });
@@ -1,6 +1,8 @@
1
+ import * as jose from 'jose';
1
2
  export declare class AccessToken {
2
3
  readonly token: string;
3
4
  constructor(token: string);
5
+ get decoded(): jose.JWTPayload;
4
6
  get expiresAt(): Date;
5
7
  /**
6
8
  * @returns The number of milliseconds until the access token expires, or 0 if it has already expired.
package/dist/sessions.js CHANGED
@@ -8,8 +8,11 @@ export class AccessToken {
8
8
  throw new StackAssertionError("Access token is the string 'undefined'; it's unlikely this is the correct value. They're supposed to be unguessable!");
9
9
  }
10
10
  }
11
+ get decoded() {
12
+ return jose.decodeJwt(this.token);
13
+ }
11
14
  get expiresAt() {
12
- const { exp } = jose.decodeJwt(this.token);
15
+ const { exp } = this.decoded;
13
16
  if (exp === undefined)
14
17
  return new Date(8640000000000000); // max date value
15
18
  return new Date(exp * 1000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackframe/stack-shared",
3
- "version": "2.7.29",
3
+ "version": "2.8.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",