@stackframe/stack-shared 2.5.33 → 2.5.37

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 (36) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/interface/clientInterface.d.ts +1 -0
  3. package/dist/interface/clientInterface.js +5 -0
  4. package/dist/interface/crud/current-user.d.ts +5 -5
  5. package/dist/interface/crud/current-user.js +2 -2
  6. package/dist/interface/crud/projects.d.ts +26 -12
  7. package/dist/interface/crud/projects.js +3 -0
  8. package/dist/interface/crud/team-member-profiles.d.ts +4 -4
  9. package/dist/interface/crud/users.d.ts +16 -14
  10. package/dist/interface/crud/users.js +4 -1
  11. package/dist/interface/webhooks.d.ts +8 -4
  12. package/dist/schema-fields.d.ts +3 -2
  13. package/dist/schema-fields.js +1 -0
  14. package/dist/utils/oauth.d.ts +3 -3
  15. package/dist/utils/oauth.js +3 -3
  16. package/dist/utils/promises.d.ts +7 -0
  17. package/dist/utils/promises.js +10 -0
  18. package/package.json +2 -2
  19. package/dist/interface/crud-deprecated/api-keys.d.ts +0 -134
  20. package/dist/interface/crud-deprecated/api-keys.js +0 -61
  21. package/dist/interface/crud-deprecated/current-user.d.ts +0 -127
  22. package/dist/interface/crud-deprecated/current-user.js +0 -49
  23. package/dist/interface/crud-deprecated/email-templates.d.ts +0 -75
  24. package/dist/interface/crud-deprecated/email-templates.js +0 -41
  25. package/dist/interface/crud-deprecated/oauth.d.ts +0 -24
  26. package/dist/interface/crud-deprecated/oauth.js +0 -12
  27. package/dist/interface/crud-deprecated/projects.d.ts +0 -440
  28. package/dist/interface/crud-deprecated/projects.js +0 -109
  29. package/dist/interface/crud-deprecated/team-memberships.d.ts +0 -22
  30. package/dist/interface/crud-deprecated/team-memberships.js +0 -22
  31. package/dist/interface/crud-deprecated/team-permissions.d.ts +0 -129
  32. package/dist/interface/crud-deprecated/team-permissions.js +0 -83
  33. package/dist/interface/crud-deprecated/teams.d.ts +0 -126
  34. package/dist/interface/crud-deprecated/teams.js +0 -78
  35. package/dist/interface/crud-deprecated/users.d.ts +0 -201
  36. package/dist/interface/crud-deprecated/users.js +0 -75
@@ -79,6 +79,16 @@ export function pending(promise, options = {}) {
79
79
  res.status = "pending";
80
80
  return res;
81
81
  }
82
+ /**
83
+ * Should be used to wrap Promises that are not immediately awaited, so they don't throw an unhandled promise rejection
84
+ * error.
85
+ *
86
+ * Vercel kills serverless functions on unhandled promise rejection errors, so this is important.
87
+ */
88
+ export function ignoreUnhandledRejection(promise) {
89
+ promise.catch(() => { });
90
+ return promise;
91
+ }
82
92
  export async function wait(ms) {
83
93
  return await new Promise(resolve => setTimeout(resolve, ms));
84
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackframe/stack-shared",
3
- "version": "2.5.33",
3
+ "version": "2.5.37",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -37,7 +37,7 @@
37
37
  "jose": "^5.2.2",
38
38
  "oauth4webapi": "^2.10.3",
39
39
  "uuid": "^9.0.1",
40
- "@stackframe/stack-sc": "2.5.33"
40
+ "@stackframe/stack-sc": "2.5.37"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/bcrypt": "^5.0.2",
@@ -1,134 +0,0 @@
1
- import { CrudTypeOf } from "../../crud";
2
- export declare const apiKeysCreateInputSchema: import("yup").ObjectSchema<{
3
- description: string;
4
- expires_at_millis: number;
5
- has_publishable_client_key: NonNullable<boolean | undefined>;
6
- has_secret_server_key: NonNullable<boolean | undefined>;
7
- has_super_secret_admin_key: NonNullable<boolean | undefined>;
8
- }, import("yup").AnyObject, {
9
- description: undefined;
10
- expires_at_millis: undefined;
11
- has_publishable_client_key: undefined;
12
- has_secret_server_key: undefined;
13
- has_super_secret_admin_key: undefined;
14
- }, "">;
15
- export declare const apiKeysCreateOutputSchema: import("yup").ObjectSchema<{
16
- id: string;
17
- description: string;
18
- expires_at_millis: number;
19
- manually_revoked_at_millis: number | undefined;
20
- created_at_millis: number;
21
- } & {
22
- publishable_client_key: string | undefined;
23
- secret_server_key: string | undefined;
24
- super_secret_admin_key: string | undefined;
25
- }, import("yup").AnyObject, {
26
- id: undefined;
27
- description: undefined;
28
- expires_at_millis: undefined;
29
- manually_revoked_at_millis: undefined;
30
- created_at_millis: undefined;
31
- publishable_client_key: undefined;
32
- secret_server_key: undefined;
33
- super_secret_admin_key: undefined;
34
- }, "">;
35
- export declare const apiKeysCrudAdminObfuscatedReadSchema: import("yup").ObjectSchema<{
36
- id: string;
37
- description: string;
38
- expires_at_millis: number;
39
- manually_revoked_at_millis: number | undefined;
40
- created_at_millis: number;
41
- } & {
42
- publishable_client_key: {
43
- last_four: string;
44
- } | undefined;
45
- secret_server_key: {
46
- last_four: string;
47
- } | undefined;
48
- super_secret_admin_key: {
49
- last_four: string;
50
- } | undefined;
51
- }, import("yup").AnyObject, {
52
- id: undefined;
53
- description: undefined;
54
- expires_at_millis: undefined;
55
- manually_revoked_at_millis: undefined;
56
- created_at_millis: undefined;
57
- publishable_client_key: {
58
- last_four: undefined;
59
- };
60
- secret_server_key: {
61
- last_four: undefined;
62
- };
63
- super_secret_admin_key: {
64
- last_four: undefined;
65
- };
66
- }, "">;
67
- export declare const apiKeysCrudAdminUpdateSchema: import("yup").ObjectSchema<{
68
- description: string | undefined;
69
- revoked: boolean | undefined;
70
- }, import("yup").AnyObject, {
71
- description: undefined;
72
- revoked: undefined;
73
- }, "">;
74
- export declare const apiKeysCrudAdminDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
75
- export declare const apiKeysCrud: import("../../crud").CrudSchemaFromOptions<{
76
- adminReadSchema: import("yup").ObjectSchema<{
77
- id: string;
78
- description: string;
79
- expires_at_millis: number;
80
- manually_revoked_at_millis: number | undefined;
81
- created_at_millis: number;
82
- } & {
83
- publishable_client_key: {
84
- last_four: string;
85
- } | undefined;
86
- secret_server_key: {
87
- last_four: string;
88
- } | undefined;
89
- super_secret_admin_key: {
90
- last_four: string;
91
- } | undefined;
92
- }, import("yup").AnyObject, {
93
- id: undefined;
94
- description: undefined;
95
- expires_at_millis: undefined;
96
- manually_revoked_at_millis: undefined;
97
- created_at_millis: undefined;
98
- publishable_client_key: {
99
- last_four: undefined;
100
- };
101
- secret_server_key: {
102
- last_four: undefined;
103
- };
104
- super_secret_admin_key: {
105
- last_four: undefined;
106
- };
107
- }, "">;
108
- adminUpdateSchema: import("yup").ObjectSchema<{
109
- description: string | undefined;
110
- revoked: boolean | undefined;
111
- }, import("yup").AnyObject, {
112
- description: undefined;
113
- revoked: undefined;
114
- }, "">;
115
- adminDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
116
- docs: {
117
- adminList: {
118
- hidden: true;
119
- };
120
- adminRead: {
121
- hidden: true;
122
- };
123
- adminCreate: {
124
- hidden: true;
125
- };
126
- adminUpdate: {
127
- hidden: true;
128
- };
129
- adminDelete: {
130
- hidden: true;
131
- };
132
- };
133
- }>;
134
- export type ApiKeysCrud = CrudTypeOf<typeof apiKeysCrud>;
@@ -1,61 +0,0 @@
1
- import { createCrud } from "../../crud";
2
- import { yupBoolean, yupMixed, yupNumber, yupObject, yupString } from "../../schema-fields";
3
- const baseApiKeysReadSchema = yupObject({
4
- id: yupString().required(),
5
- description: yupString().required(),
6
- expires_at_millis: yupNumber().required(),
7
- manually_revoked_at_millis: yupNumber().optional(),
8
- created_at_millis: yupNumber().required(),
9
- });
10
- // Used for the result of the create endpoint
11
- export const apiKeysCreateInputSchema = yupObject({
12
- description: yupString().required(),
13
- expires_at_millis: yupNumber().required(),
14
- has_publishable_client_key: yupBoolean().required(),
15
- has_secret_server_key: yupBoolean().required(),
16
- has_super_secret_admin_key: yupBoolean().required(),
17
- });
18
- export const apiKeysCreateOutputSchema = baseApiKeysReadSchema.concat(yupObject({
19
- publishable_client_key: yupString().optional(),
20
- secret_server_key: yupString().optional(),
21
- super_secret_admin_key: yupString().optional(),
22
- }).required());
23
- // Used for list, read and update endpoints after the initial creation
24
- export const apiKeysCrudAdminObfuscatedReadSchema = baseApiKeysReadSchema.concat(yupObject({
25
- publishable_client_key: yupObject({
26
- last_four: yupString().required(),
27
- }).optional(),
28
- secret_server_key: yupObject({
29
- last_four: yupString().required(),
30
- }).optional(),
31
- super_secret_admin_key: yupObject({
32
- last_four: yupString().required(),
33
- }).optional(),
34
- }));
35
- export const apiKeysCrudAdminUpdateSchema = yupObject({
36
- description: yupString().optional(),
37
- revoked: yupBoolean().oneOf([true]).optional(),
38
- }).required();
39
- export const apiKeysCrudAdminDeleteSchema = yupMixed();
40
- export const apiKeysCrud = createCrud({
41
- adminReadSchema: apiKeysCrudAdminObfuscatedReadSchema,
42
- adminUpdateSchema: apiKeysCrudAdminUpdateSchema,
43
- adminDeleteSchema: apiKeysCrudAdminDeleteSchema,
44
- docs: {
45
- adminList: {
46
- hidden: true,
47
- },
48
- adminRead: {
49
- hidden: true,
50
- },
51
- adminCreate: {
52
- hidden: true,
53
- },
54
- adminUpdate: {
55
- hidden: true,
56
- },
57
- adminDelete: {
58
- hidden: true,
59
- },
60
- },
61
- });
@@ -1,127 +0,0 @@
1
- import { CrudTypeOf } from "../../crud";
2
- export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions<{
3
- clientReadSchema: import("yup").ObjectSchema<{
4
- id: string;
5
- display_name: string | null;
6
- oauth_providers: {
7
- email?: string | null | undefined;
8
- provider_id: string;
9
- account_id: string;
10
- }[];
11
- project_id: string;
12
- primary_email: string | null;
13
- profile_image_url: string | null;
14
- client_metadata: {} | null;
15
- primary_email_verified: NonNullable<boolean | undefined>;
16
- selected_team_id: string | null;
17
- selected_team: {} | null;
18
- signed_up_at_millis: number;
19
- has_password: NonNullable<boolean | undefined>;
20
- auth_with_email: NonNullable<boolean | undefined>;
21
- } | null, import("yup").AnyObject, {
22
- project_id: undefined;
23
- id: undefined;
24
- primary_email: undefined;
25
- primary_email_verified: undefined;
26
- display_name: undefined;
27
- selected_team: undefined;
28
- selected_team_id: undefined;
29
- profile_image_url: undefined;
30
- signed_up_at_millis: undefined;
31
- has_password: undefined;
32
- auth_with_email: undefined;
33
- oauth_providers: undefined;
34
- client_metadata: undefined;
35
- server_metadata: undefined;
36
- }, "">;
37
- serverReadSchema: import("yup").ObjectSchema<{
38
- project_id: string;
39
- id: string;
40
- primary_email: string | null;
41
- primary_email_verified: NonNullable<boolean | undefined>;
42
- display_name: string | null;
43
- selected_team: {} | null;
44
- selected_team_id: string | null;
45
- profile_image_url: string | null;
46
- signed_up_at_millis: number;
47
- has_password: NonNullable<boolean | undefined>;
48
- auth_with_email: NonNullable<boolean | undefined>;
49
- oauth_providers: {
50
- email?: string | null | undefined;
51
- provider_id: string;
52
- account_id: string;
53
- }[];
54
- client_metadata: {} | null;
55
- server_metadata: {} | null;
56
- } | null, import("yup").AnyObject, {
57
- project_id: undefined;
58
- id: undefined;
59
- primary_email: undefined;
60
- primary_email_verified: undefined;
61
- display_name: undefined;
62
- selected_team: undefined;
63
- selected_team_id: undefined;
64
- profile_image_url: undefined;
65
- signed_up_at_millis: undefined;
66
- has_password: undefined;
67
- auth_with_email: undefined;
68
- oauth_providers: undefined;
69
- client_metadata: undefined;
70
- server_metadata: undefined;
71
- }, "">;
72
- clientUpdateSchema: import("yup").ObjectSchema<{
73
- display_name: string | null | undefined;
74
- client_metadata: {} | null | undefined;
75
- selected_team_id: string | null | undefined;
76
- }, import("yup").AnyObject, {
77
- display_name: undefined;
78
- profile_image_url: undefined;
79
- client_metadata: undefined;
80
- server_metadata: undefined;
81
- primary_email: undefined;
82
- primary_email_verified: undefined;
83
- primary_email_auth_enabled: undefined;
84
- password: undefined;
85
- selected_team_id: undefined;
86
- }, "">;
87
- serverUpdateSchema: import("yup").ObjectSchema<{
88
- display_name: string | null | undefined;
89
- profile_image_url: string | undefined;
90
- client_metadata: {} | null | undefined;
91
- server_metadata: {} | null | undefined;
92
- primary_email: string | null | undefined;
93
- primary_email_verified: boolean | undefined;
94
- primary_email_auth_enabled: boolean | undefined;
95
- password: string | null | undefined;
96
- selected_team_id: string | null | undefined;
97
- }, import("yup").AnyObject, {
98
- display_name: undefined;
99
- profile_image_url: undefined;
100
- client_metadata: undefined;
101
- server_metadata: undefined;
102
- primary_email: undefined;
103
- primary_email_verified: undefined;
104
- primary_email_auth_enabled: undefined;
105
- password: undefined;
106
- selected_team_id: undefined;
107
- }, "">;
108
- serverDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
109
- docs: {
110
- clientRead: {
111
- summary: string;
112
- description: string;
113
- tags: string[];
114
- };
115
- clientUpdate: {
116
- summary: string;
117
- description: string;
118
- tags: string[];
119
- };
120
- clientDelete: {
121
- summary: string;
122
- description: string;
123
- tags: string[];
124
- };
125
- };
126
- }>;
127
- export type CurrentUserCrud = CrudTypeOf<typeof currentUserCrud>;
@@ -1,49 +0,0 @@
1
- import { createCrud } from "../../crud";
2
- import { usersCrudServerReadSchema, usersCrudServerUpdateSchema, usersCrudServerDeleteSchema } from "./users";
3
- const clientUpdateSchema = usersCrudServerUpdateSchema.pick([
4
- "display_name",
5
- "client_metadata",
6
- "selected_team_id",
7
- ]).required();
8
- const serverUpdateSchema = usersCrudServerUpdateSchema;
9
- const clientReadSchema = usersCrudServerReadSchema.pick([
10
- "project_id",
11
- "id",
12
- "primary_email",
13
- "primary_email_verified",
14
- "display_name",
15
- "client_metadata",
16
- "profile_image_url",
17
- "signed_up_at_millis",
18
- "has_password",
19
- "auth_with_email",
20
- "oauth_providers",
21
- "selected_team_id",
22
- "selected_team",
23
- ]).nullable().defined();
24
- const serverReadSchema = usersCrudServerReadSchema.nullable().defined();
25
- const serverDeleteSchema = usersCrudServerDeleteSchema;
26
- export const currentUserCrud = createCrud({
27
- clientReadSchema,
28
- serverReadSchema,
29
- clientUpdateSchema,
30
- serverUpdateSchema,
31
- serverDeleteSchema,
32
- docs: {
33
- clientRead: {
34
- summary: 'Get current user',
35
- description: 'Gets the currently authenticated user.',
36
- tags: ['Users'],
37
- },
38
- clientUpdate: {
39
- summary: 'Update current user',
40
- description: 'Updates the currently authenticated user. Only the values provided will be updated.',
41
- tags: ['Users'],
42
- },
43
- clientDelete: {
44
- summary: 'Delete current user',
45
- description: 'Deletes the currently authenticated user. Use this with caution.',
46
- tags: ['Users'],
47
- },
48
- },
49
- });
@@ -1,75 +0,0 @@
1
- import { CrudTypeOf } from "../../crud";
2
- export type EmailTemplateType = typeof emailTemplateTypes[number];
3
- export declare const emailTemplateTypes: readonly ["EMAIL_VERIFICATION", "PASSWORD_RESET", "MAGIC_LINK", "TEAM_INVITATION"];
4
- export declare const emailTemplateServerReadSchema: import("yup").ObjectSchema<{
5
- type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | "TEAM_INVITATION" | undefined>;
6
- subject: string;
7
- content: {};
8
- }, import("yup").AnyObject, {
9
- type: undefined;
10
- subject: undefined;
11
- content: undefined;
12
- }, "">;
13
- export declare const emailTemplateCrudServerUpdateSchema: import("yup").ObjectSchema<{
14
- content: {};
15
- subject: string;
16
- }, import("yup").AnyObject, {
17
- content: undefined;
18
- subject: undefined;
19
- }, "">;
20
- export declare const emailTemplateCrudServerDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
21
- export declare const emailTemplateCrudServerCreateSchema: import("yup").ObjectSchema<{
22
- type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | "TEAM_INVITATION" | undefined>;
23
- content: {};
24
- subject: string;
25
- }, import("yup").AnyObject, {
26
- type: undefined;
27
- content: undefined;
28
- subject: undefined;
29
- }, "">;
30
- export declare const emailTemplateCrud: import("../../crud").CrudSchemaFromOptions<{
31
- serverReadSchema: import("yup").ObjectSchema<{
32
- type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | "TEAM_INVITATION" | undefined>;
33
- subject: string;
34
- content: {};
35
- }, import("yup").AnyObject, {
36
- type: undefined;
37
- subject: undefined;
38
- content: undefined;
39
- }, "">;
40
- serverUpdateSchema: import("yup").ObjectSchema<{
41
- content: {};
42
- subject: string;
43
- }, import("yup").AnyObject, {
44
- content: undefined;
45
- subject: undefined;
46
- }, "">;
47
- serverCreateSchema: import("yup").ObjectSchema<{
48
- type: NonNullable<"EMAIL_VERIFICATION" | "PASSWORD_RESET" | "MAGIC_LINK" | "TEAM_INVITATION" | undefined>;
49
- content: {};
50
- subject: string;
51
- }, import("yup").AnyObject, {
52
- type: undefined;
53
- content: undefined;
54
- subject: undefined;
55
- }, "">;
56
- serverDeleteSchema: import("yup").MixedSchema<{} | undefined, import("yup").AnyObject, undefined, "">;
57
- docs: {
58
- serverRead: {
59
- hidden: true;
60
- };
61
- serverCreate: {
62
- hidden: true;
63
- };
64
- serverUpdate: {
65
- hidden: true;
66
- };
67
- serverDelete: {
68
- hidden: true;
69
- };
70
- serverList: {
71
- hidden: true;
72
- };
73
- };
74
- }>;
75
- export type EmailTemplateCrud = CrudTypeOf<typeof emailTemplateCrud>;
@@ -1,41 +0,0 @@
1
- import { createCrud } from "../../crud";
2
- import { jsonSchema, yupMixed, yupObject, yupString } from "../../schema-fields";
3
- export const emailTemplateTypes = ['EMAIL_VERIFICATION', 'PASSWORD_RESET', 'MAGIC_LINK', 'TEAM_INVITATION'];
4
- export const emailTemplateServerReadSchema = yupObject({
5
- type: yupString().oneOf(emailTemplateTypes).required(),
6
- subject: yupString().required(),
7
- content: jsonSchema.required(),
8
- }).required();
9
- export const emailTemplateCrudServerUpdateSchema = yupObject({
10
- content: jsonSchema.required(),
11
- subject: yupString().required(),
12
- }).required();
13
- export const emailTemplateCrudServerDeleteSchema = yupMixed();
14
- export const emailTemplateCrudServerCreateSchema = yupObject({
15
- type: yupString().oneOf(emailTemplateTypes).required(),
16
- content: jsonSchema.required(),
17
- subject: yupString().required(),
18
- }).required();
19
- export const emailTemplateCrud = createCrud({
20
- serverReadSchema: emailTemplateServerReadSchema,
21
- serverUpdateSchema: emailTemplateCrudServerUpdateSchema,
22
- serverCreateSchema: emailTemplateCrudServerCreateSchema,
23
- serverDeleteSchema: emailTemplateCrudServerDeleteSchema,
24
- docs: {
25
- serverRead: {
26
- hidden: true,
27
- },
28
- serverCreate: {
29
- hidden: true,
30
- },
31
- serverUpdate: {
32
- hidden: true,
33
- },
34
- serverDelete: {
35
- hidden: true,
36
- },
37
- serverList: {
38
- hidden: true,
39
- }
40
- }
41
- });
@@ -1,24 +0,0 @@
1
- import { CrudTypeOf } from "../../crud";
2
- export declare const accessTokenReadSchema: import("yup").ObjectSchema<{
3
- access_token: string;
4
- }, import("yup").AnyObject, {
5
- access_token: undefined;
6
- }, "">;
7
- export declare const accessTokenCreateSchema: import("yup").ObjectSchema<{
8
- scope: string | undefined;
9
- }, import("yup").AnyObject, {
10
- scope: undefined;
11
- }, "">;
12
- export declare const accessTokenCrud: import("../../crud").CrudSchemaFromOptions<{
13
- clientReadSchema: import("yup").ObjectSchema<{
14
- access_token: string;
15
- }, import("yup").AnyObject, {
16
- access_token: undefined;
17
- }, "">;
18
- clientCreateSchema: import("yup").ObjectSchema<{
19
- scope: string | undefined;
20
- }, import("yup").AnyObject, {
21
- scope: undefined;
22
- }, "">;
23
- }>;
24
- export type AccessTokenCrud = CrudTypeOf<typeof accessTokenCrud>;
@@ -1,12 +0,0 @@
1
- import { createCrud } from "../../crud";
2
- import { yupObject, yupString } from "../../schema-fields";
3
- export const accessTokenReadSchema = yupObject({
4
- access_token: yupString().required(),
5
- }).required();
6
- export const accessTokenCreateSchema = yupObject({
7
- scope: yupString().optional(),
8
- }).required();
9
- export const accessTokenCrud = createCrud({
10
- clientReadSchema: accessTokenReadSchema,
11
- clientCreateSchema: accessTokenCreateSchema,
12
- });