@stackframe/stack-shared 2.4.22 → 2.4.24
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 +14 -0
- package/dist/interface/clientInterface.d.ts +4 -0
- package/dist/interface/clientInterface.js +10 -0
- package/dist/interface/crud/current-user.d.ts +6 -0
- package/dist/interface/crud/current-user.js +1 -0
- package/dist/interface/crud/users.d.ts +7 -3
- package/dist/interface/crud/users.js +2 -0
- package/dist/interface/serverInterface.d.ts +3 -1
- package/dist/known-errors.d.ts +3 -0
- package/dist/known-errors.js +5 -0
- package/dist/utils/react.js +6 -6
- package/package.json +12 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @stackframe/stack-shared
|
|
2
2
|
|
|
3
|
+
## 2.4.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Team switcher
|
|
8
|
+
- @stackframe/stack-sc@2.4.24
|
|
9
|
+
|
|
10
|
+
## 2.4.23
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Bugfixes
|
|
15
|
+
- @stackframe/stack-sc@2.4.23
|
|
16
|
+
|
|
3
17
|
## 2.4.22
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -25,6 +25,7 @@ export type UserJson = UserCustomizableJson & {
|
|
|
25
25
|
authWithEmail: boolean;
|
|
26
26
|
oauthProviders: string[];
|
|
27
27
|
selectedTeamId: string | null;
|
|
28
|
+
selectedTeam: TeamJson | null;
|
|
28
29
|
};
|
|
29
30
|
export type UserUpdateJson = Partial<UserCustomizableJson>;
|
|
30
31
|
export type ClientProjectJson = {
|
|
@@ -143,6 +144,9 @@ export declare class StackClientInterface {
|
|
|
143
144
|
}, InstanceType<E>>>;
|
|
144
145
|
private sendClientRequestInner;
|
|
145
146
|
private _processResponse;
|
|
147
|
+
checkFeatureSupport(options: {
|
|
148
|
+
featureName?: string;
|
|
149
|
+
} & ReadonlyJson): Promise<never>;
|
|
146
150
|
sendForgotPasswordEmail(email: string, redirectUrl: string): Promise<KnownErrors["UserNotFound"] | undefined>;
|
|
147
151
|
sendVerificationEmail(emailVerificationRedirectUrl: string, session: InternalSession): Promise<KnownErrors["EmailAlreadyVerified"] | undefined>;
|
|
148
152
|
sendMagicLinkEmail(email: string, redirectUrl: string): Promise<KnownErrors["RedirectUrlNotWhitelisted"] | undefined>;
|
|
@@ -231,6 +231,16 @@ export class StackClientInterface {
|
|
|
231
231
|
}
|
|
232
232
|
return Result.ok(res);
|
|
233
233
|
}
|
|
234
|
+
async checkFeatureSupport(options) {
|
|
235
|
+
const res = await this.sendClientRequest("/check-feature-support", {
|
|
236
|
+
method: "POST",
|
|
237
|
+
headers: {
|
|
238
|
+
"Content-Type": "application/json",
|
|
239
|
+
},
|
|
240
|
+
body: JSON.stringify(options),
|
|
241
|
+
}, null);
|
|
242
|
+
throw new StackAssertionError(await res.text());
|
|
243
|
+
}
|
|
234
244
|
async sendForgotPasswordEmail(email, redirectUrl) {
|
|
235
245
|
const res = await this.sendClientRequestAndCatchKnownError("/auth/forgot-password", {
|
|
236
246
|
method: "POST",
|
|
@@ -11,6 +11,7 @@ export declare const currentUserCrud: {
|
|
|
11
11
|
primaryEmail: string | null;
|
|
12
12
|
primaryEmailVerified: NonNullable<boolean | undefined>;
|
|
13
13
|
selectedTeamId: string | null;
|
|
14
|
+
selectedTeam: {} | null;
|
|
14
15
|
profileImageUrl: string | null;
|
|
15
16
|
signedUpAtMillis: number;
|
|
16
17
|
authMethod: NonNullable<"credential" | "oauth" | undefined>;
|
|
@@ -25,6 +26,7 @@ export declare const currentUserCrud: {
|
|
|
25
26
|
displayName: undefined;
|
|
26
27
|
clientMetadata: undefined;
|
|
27
28
|
selectedTeamId: undefined;
|
|
29
|
+
selectedTeam: undefined;
|
|
28
30
|
profileImageUrl: undefined;
|
|
29
31
|
signedUpAtMillis: undefined;
|
|
30
32
|
authMethod: undefined;
|
|
@@ -57,6 +59,7 @@ export declare const currentUserCrud: {
|
|
|
57
59
|
displayName: string | null;
|
|
58
60
|
clientMetadata: {} | null;
|
|
59
61
|
selectedTeamId: string | null;
|
|
62
|
+
selectedTeam: {} | null;
|
|
60
63
|
profileImageUrl: string | null;
|
|
61
64
|
signedUpAtMillis: number;
|
|
62
65
|
authMethod: NonNullable<"credential" | "oauth" | undefined>;
|
|
@@ -72,6 +75,7 @@ export declare const currentUserCrud: {
|
|
|
72
75
|
displayName: undefined;
|
|
73
76
|
clientMetadata: undefined;
|
|
74
77
|
selectedTeamId: undefined;
|
|
78
|
+
selectedTeam: undefined;
|
|
75
79
|
profileImageUrl: undefined;
|
|
76
80
|
signedUpAtMillis: undefined;
|
|
77
81
|
authMethod: undefined;
|
|
@@ -107,6 +111,7 @@ export declare const currentUserCrud: {
|
|
|
107
111
|
displayName: string | null;
|
|
108
112
|
clientMetadata: {} | null;
|
|
109
113
|
selectedTeamId: string | null;
|
|
114
|
+
selectedTeam: {} | null;
|
|
110
115
|
profileImageUrl: string | null;
|
|
111
116
|
signedUpAtMillis: number;
|
|
112
117
|
authMethod: NonNullable<"credential" | "oauth" | undefined>;
|
|
@@ -122,6 +127,7 @@ export declare const currentUserCrud: {
|
|
|
122
127
|
displayName: undefined;
|
|
123
128
|
clientMetadata: undefined;
|
|
124
129
|
selectedTeamId: undefined;
|
|
130
|
+
selectedTeam: undefined;
|
|
125
131
|
profileImageUrl: undefined;
|
|
126
132
|
signedUpAtMillis: undefined;
|
|
127
133
|
authMethod: undefined;
|
|
@@ -20,6 +20,7 @@ const clientReadSchema = usersCrudServerReadSchema.pick([
|
|
|
20
20
|
"authWithEmail",
|
|
21
21
|
"oauthProviders",
|
|
22
22
|
"selectedTeamId",
|
|
23
|
+
"selectedTeam",
|
|
23
24
|
]).nullable().defined();
|
|
24
25
|
const serverReadSchema = usersCrudServerReadSchema.nullable().defined();
|
|
25
26
|
export const currentUserCrud = createCrud({
|
|
@@ -23,6 +23,7 @@ export declare const usersCrudServerReadSchema: yup.ObjectSchema<{
|
|
|
23
23
|
displayName: string | null;
|
|
24
24
|
clientMetadata: {} | null;
|
|
25
25
|
selectedTeamId: string | null;
|
|
26
|
+
selectedTeam: {} | null;
|
|
26
27
|
profileImageUrl: string | null;
|
|
27
28
|
signedUpAtMillis: number;
|
|
28
29
|
authMethod: NonNullable<"credential" | "oauth" | undefined>;
|
|
@@ -38,6 +39,7 @@ export declare const usersCrudServerReadSchema: yup.ObjectSchema<{
|
|
|
38
39
|
displayName: undefined;
|
|
39
40
|
clientMetadata: undefined;
|
|
40
41
|
selectedTeamId: undefined;
|
|
42
|
+
selectedTeam: undefined;
|
|
41
43
|
profileImageUrl: undefined;
|
|
42
44
|
signedUpAtMillis: undefined;
|
|
43
45
|
authMethod: undefined;
|
|
@@ -63,6 +65,7 @@ export declare const usersCrud: {
|
|
|
63
65
|
displayName: string | null;
|
|
64
66
|
clientMetadata: {} | null;
|
|
65
67
|
selectedTeamId: string | null;
|
|
68
|
+
selectedTeam: {} | null;
|
|
66
69
|
profileImageUrl: string | null;
|
|
67
70
|
signedUpAtMillis: number;
|
|
68
71
|
authMethod: NonNullable<"credential" | "oauth" | undefined>;
|
|
@@ -78,6 +81,7 @@ export declare const usersCrud: {
|
|
|
78
81
|
displayName: undefined;
|
|
79
82
|
clientMetadata: undefined;
|
|
80
83
|
selectedTeamId: undefined;
|
|
84
|
+
selectedTeam: undefined;
|
|
81
85
|
profileImageUrl: undefined;
|
|
82
86
|
signedUpAtMillis: undefined;
|
|
83
87
|
authMethod: undefined;
|
|
@@ -102,9 +106,7 @@ export declare const usersCrud: {
|
|
|
102
106
|
selectedTeamId: undefined;
|
|
103
107
|
}, "">;
|
|
104
108
|
deleteSchema: yup.MixedSchema<{} | undefined, yup.AnyObject, undefined, "">;
|
|
105
|
-
};
|
|
106
|
-
* not used anymore, for backwards compatibility
|
|
107
|
-
*/
|
|
109
|
+
};
|
|
108
110
|
admin: {
|
|
109
111
|
createSchema: undefined;
|
|
110
112
|
readSchema: yup.ObjectSchema<{
|
|
@@ -115,6 +117,7 @@ export declare const usersCrud: {
|
|
|
115
117
|
displayName: string | null;
|
|
116
118
|
clientMetadata: {} | null;
|
|
117
119
|
selectedTeamId: string | null;
|
|
120
|
+
selectedTeam: {} | null;
|
|
118
121
|
profileImageUrl: string | null;
|
|
119
122
|
signedUpAtMillis: number;
|
|
120
123
|
authMethod: NonNullable<"credential" | "oauth" | undefined>;
|
|
@@ -130,6 +133,7 @@ export declare const usersCrud: {
|
|
|
130
133
|
displayName: undefined;
|
|
131
134
|
clientMetadata: undefined;
|
|
132
135
|
selectedTeamId: undefined;
|
|
136
|
+
selectedTeam: undefined;
|
|
133
137
|
profileImageUrl: undefined;
|
|
134
138
|
signedUpAtMillis: undefined;
|
|
135
139
|
authMethod: undefined;
|
|
@@ -17,6 +17,8 @@ export const usersCrudServerReadSchema = yup.object({
|
|
|
17
17
|
displayName: yup.string().nullable().defined(),
|
|
18
18
|
clientMetadata: yupJson,
|
|
19
19
|
selectedTeamId: yup.string().nullable().defined(),
|
|
20
|
+
// TODO give this one the type of an actual team
|
|
21
|
+
selectedTeam: yup.mixed().nullable().defined(),
|
|
20
22
|
profileImageUrl: yup.string().nullable().defined(),
|
|
21
23
|
signedUpAtMillis: yup.number().required(),
|
|
22
24
|
/**
|
|
@@ -15,7 +15,9 @@ export type ServerOrglikeCustomizableJson = Pick<ServerOrglikeJson, "displayName
|
|
|
15
15
|
export type ServerOrglikeJson = OrglikeJson & {};
|
|
16
16
|
export type ServerTeamCustomizableJson = ServerOrglikeCustomizableJson;
|
|
17
17
|
export type ServerTeamJson = ServerOrglikeJson;
|
|
18
|
-
export type ServerTeamMemberJson = TeamMemberJson
|
|
18
|
+
export type ServerTeamMemberJson = TeamMemberJson & {
|
|
19
|
+
user: ServerUserJson;
|
|
20
|
+
};
|
|
19
21
|
export type ServerPermissionDefinitionCustomizableJson = {
|
|
20
22
|
readonly id: string;
|
|
21
23
|
readonly description?: string;
|
package/dist/known-errors.d.ts
CHANGED
|
@@ -263,5 +263,8 @@ export declare const KnownErrors: {
|
|
|
263
263
|
UserAlreadyConnectedToAnotherOAuthConnection: KnownErrorConstructor<KnownError & KnownErrorBrand<"USER_ALREADY_CONNECTED_TO_ANOTHER_OAUTH_CONNECTION">, []> & {
|
|
264
264
|
errorCode: "USER_ALREADY_CONNECTED_TO_ANOTHER_OAUTH_CONNECTION";
|
|
265
265
|
};
|
|
266
|
+
OuterOAuthTimeout: KnownErrorConstructor<KnownError & KnownErrorBrand<"OUTER_OAUTH_TIMEOUT">, []> & {
|
|
267
|
+
errorCode: "OUTER_OAUTH_TIMEOUT";
|
|
268
|
+
};
|
|
266
269
|
};
|
|
267
270
|
export {};
|
package/dist/known-errors.js
CHANGED
|
@@ -365,6 +365,10 @@ const UserAlreadyConnectedToAnotherOAuthConnection = createKnownErrorConstructor
|
|
|
365
365
|
400,
|
|
366
366
|
"The user is already connected to another OAuth account. Did you maybe selected the wrong account?",
|
|
367
367
|
], () => []);
|
|
368
|
+
const OuterOAuthTimeout = createKnownErrorConstructor(KnownError, "OUTER_OAUTH_TIMEOUT", () => [
|
|
369
|
+
408,
|
|
370
|
+
"The OAuth flow has timed out. Please sign in again.",
|
|
371
|
+
], () => []);
|
|
368
372
|
export const KnownErrors = {
|
|
369
373
|
UnsupportedError,
|
|
370
374
|
BodyParsingError,
|
|
@@ -439,6 +443,7 @@ export const KnownErrors = {
|
|
|
439
443
|
OAuthExtraScopeNotAvailableWithSharedOAuthKeys,
|
|
440
444
|
OAuthAccessTokenNotAvailableWithSharedOAuthKeys,
|
|
441
445
|
UserAlreadyConnectedToAnotherOAuthConnection,
|
|
446
|
+
OuterOAuthTimeout,
|
|
442
447
|
};
|
|
443
448
|
// ensure that all known error codes are unique
|
|
444
449
|
const knownErrorCodes = new Set();
|
package/dist/utils/react.js
CHANGED
|
@@ -41,12 +41,12 @@ export function suspendIfSsr(caller) {
|
|
|
41
41
|
2. The component is rendered in the root (outermost) layout.tsx or template.tsx file. Next.js does not wrap those files in a Suspense boundary, even if there is a loading.tsx file in the same folder. To fix it, wrap your layout inside a route group like this:
|
|
42
42
|
|
|
43
43
|
- app
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
- - layout.tsx // contains <html> and <body>, alongside providers and other components that don't need ${caller ?? "this code path"}
|
|
45
|
+
- - loading.tsx // required for suspense
|
|
46
|
+
- - (main)
|
|
47
|
+
- - - layout.tsx // contains the main layout of your app, like a sidebar or a header, and can use ${caller ?? "this code path"}
|
|
48
|
+
- - - route.tsx // your actual main page
|
|
49
|
+
- - - the rest of your app
|
|
50
50
|
|
|
51
51
|
For more information on this approach, see Next's documentation on route groups: https://nextjs.org/docs/app/building-your-application/routing/route-groups
|
|
52
52
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackframe/stack-shared",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.24",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
"CHANGELOG.md",
|
|
10
10
|
"LICENSE"
|
|
11
11
|
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./dist/*": {
|
|
18
|
+
"types": "./dist/*.d.ts",
|
|
19
|
+
"default": "./dist/*.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
12
22
|
"peerDependencies": {
|
|
13
23
|
"react": "^18.2",
|
|
14
24
|
"yup": "^1.4.0"
|
|
@@ -26,7 +36,7 @@
|
|
|
26
36
|
"jose": "^5.2.2",
|
|
27
37
|
"oauth4webapi": "^2.10.3",
|
|
28
38
|
"uuid": "^9.0.1",
|
|
29
|
-
"@stackframe/stack-sc": "2.4.
|
|
39
|
+
"@stackframe/stack-sc": "2.4.24"
|
|
30
40
|
},
|
|
31
41
|
"devDependencies": {
|
|
32
42
|
"rimraf": "^5.0.5",
|