@stackframe/stack-shared 2.5.37 → 2.6.0
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 +11 -0
- package/dist/interface/clientInterface.d.ts +13 -11
- package/dist/interface/clientInterface.js +30 -16
- package/dist/interface/crud/current-user.d.ts +5 -5
- package/dist/interface/crud/projects.d.ts +12 -12
- package/dist/interface/crud/team-member-profiles.d.ts +6 -6
- package/dist/interface/crud/users.d.ts +12 -12
- package/dist/interface/webhooks.d.ts +4 -4
- package/dist/known-errors.d.ts +8 -0
- package/dist/known-errors.js +10 -0
- package/dist/schema-fields.d.ts +5 -2
- package/dist/schema-fields.js +62 -5
- package/dist/utils/jwt.d.ts +1 -1
- package/dist/utils/jwt.js +2 -2
- package/dist/utils/oauth.d.ts +2 -2
- package/dist/utils/oauth.js +1 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -51,22 +51,24 @@ export declare class StackClientInterface {
|
|
|
51
51
|
checkFeatureSupport(options: {
|
|
52
52
|
featureName?: string;
|
|
53
53
|
} & ReadonlyJson): Promise<never>;
|
|
54
|
-
sendForgotPasswordEmail(email: string, callbackUrl: string): Promise<KnownErrors["UserNotFound"]
|
|
54
|
+
sendForgotPasswordEmail(email: string, callbackUrl: string): Promise<Result<undefined, KnownErrors["UserNotFound"]>>;
|
|
55
55
|
sendVerificationEmail(email: string, callbackUrl: string, session: InternalSession): Promise<KnownErrors["EmailAlreadyVerified"] | undefined>;
|
|
56
|
-
sendMagicLinkEmail(email: string, callbackUrl: string): Promise<
|
|
56
|
+
sendMagicLinkEmail(email: string, callbackUrl: string): Promise<Result<{
|
|
57
|
+
nonce: string;
|
|
58
|
+
}, KnownErrors["RedirectUrlNotWhitelisted"]>>;
|
|
57
59
|
resetPassword(options: {
|
|
58
60
|
code: string;
|
|
59
61
|
} & ({
|
|
60
62
|
password: string;
|
|
61
63
|
} | {
|
|
62
64
|
onlyVerifyCode: true;
|
|
63
|
-
})): Promise<KnownErrors["VerificationCodeError"]
|
|
65
|
+
})): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
|
|
64
66
|
updatePassword(options: {
|
|
65
67
|
oldPassword: string;
|
|
66
68
|
newPassword: string;
|
|
67
69
|
}, session: InternalSession): Promise<KnownErrors["PasswordConfirmationMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | undefined>;
|
|
68
|
-
verifyPasswordResetCode(code: string): Promise<KnownErrors["VerificationCodeError"]
|
|
69
|
-
verifyEmail(code: string): Promise<KnownErrors["VerificationCodeError"]
|
|
70
|
+
verifyPasswordResetCode(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
|
|
71
|
+
verifyEmail(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
|
|
70
72
|
sendTeamInvitation(options: {
|
|
71
73
|
email: string;
|
|
72
74
|
teamId: string;
|
|
@@ -85,19 +87,19 @@ export declare class StackClientInterface {
|
|
|
85
87
|
refreshToken: any;
|
|
86
88
|
newUser: any;
|
|
87
89
|
}>;
|
|
88
|
-
signInWithCredential(email: string, password: string, session: InternalSession): Promise<
|
|
90
|
+
signInWithCredential(email: string, password: string, session: InternalSession): Promise<Result<{
|
|
89
91
|
accessToken: string;
|
|
90
92
|
refreshToken: string;
|
|
91
|
-
}
|
|
92
|
-
signUpWithCredential(email: string, password: string, emailVerificationRedirectUrl: string, session: InternalSession): Promise<
|
|
93
|
+
}, KnownErrors["EmailPasswordMismatch"]>>;
|
|
94
|
+
signUpWithCredential(email: string, password: string, emailVerificationRedirectUrl: string, session: InternalSession): Promise<Result<{
|
|
93
95
|
accessToken: string;
|
|
94
96
|
refreshToken: string;
|
|
95
|
-
}
|
|
96
|
-
signInWithMagicLink(code: string): Promise<
|
|
97
|
+
}, KnownErrors["UserEmailAlreadyExists"] | KnownErrors["PasswordRequirementsNotMet"]>>;
|
|
98
|
+
signInWithMagicLink(code: string): Promise<Result<{
|
|
97
99
|
newUser: boolean;
|
|
98
100
|
accessToken: string;
|
|
99
101
|
refreshToken: string;
|
|
100
|
-
}
|
|
102
|
+
}, KnownErrors["VerificationCodeError"]>>;
|
|
101
103
|
getOAuthUrl(options: {
|
|
102
104
|
provider: string;
|
|
103
105
|
redirectUrl: string;
|
|
@@ -303,7 +303,10 @@ export class StackClientInterface {
|
|
|
303
303
|
}),
|
|
304
304
|
}, null, [KnownErrors.UserNotFound]);
|
|
305
305
|
if (res.status === "error") {
|
|
306
|
-
return res.error;
|
|
306
|
+
return Result.error(res.error);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
return Result.ok(undefined);
|
|
307
310
|
}
|
|
308
311
|
}
|
|
309
312
|
async sendVerificationEmail(email, callbackUrl, session) {
|
|
@@ -333,7 +336,10 @@ export class StackClientInterface {
|
|
|
333
336
|
}),
|
|
334
337
|
}, null, [KnownErrors.RedirectUrlNotWhitelisted]);
|
|
335
338
|
if (res.status === "error") {
|
|
336
|
-
return res.error;
|
|
339
|
+
return Result.error(res.error);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
return Result.ok(await res.data.json());
|
|
337
343
|
}
|
|
338
344
|
}
|
|
339
345
|
async resetPassword(options) {
|
|
@@ -348,7 +354,10 @@ export class StackClientInterface {
|
|
|
348
354
|
}),
|
|
349
355
|
}, null, [KnownErrors.VerificationCodeError]);
|
|
350
356
|
if (res.status === "error") {
|
|
351
|
-
return res.error;
|
|
357
|
+
return Result.error(res.error);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
return Result.ok(undefined);
|
|
352
361
|
}
|
|
353
362
|
}
|
|
354
363
|
async updatePassword(options, session) {
|
|
@@ -368,10 +377,12 @@ export class StackClientInterface {
|
|
|
368
377
|
}
|
|
369
378
|
async verifyPasswordResetCode(code) {
|
|
370
379
|
const res = await this.resetPassword({ code, onlyVerifyCode: true });
|
|
371
|
-
if (res
|
|
372
|
-
|
|
380
|
+
if (res.status === "error") {
|
|
381
|
+
return Result.error(res.error);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
return Result.ok(undefined);
|
|
373
385
|
}
|
|
374
|
-
return res;
|
|
375
386
|
}
|
|
376
387
|
async verifyEmail(code) {
|
|
377
388
|
const res = await this.sendClientRequestAndCatchKnownError("/contact-channels/verify", {
|
|
@@ -384,7 +395,10 @@ export class StackClientInterface {
|
|
|
384
395
|
}),
|
|
385
396
|
}, null, [KnownErrors.VerificationCodeError]);
|
|
386
397
|
if (res.status === "error") {
|
|
387
|
-
return res.error;
|
|
398
|
+
return Result.error(res.error);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
return Result.ok(undefined);
|
|
388
402
|
}
|
|
389
403
|
}
|
|
390
404
|
async sendTeamInvitation(options) {
|
|
@@ -458,13 +472,13 @@ export class StackClientInterface {
|
|
|
458
472
|
}),
|
|
459
473
|
}, session, [KnownErrors.EmailPasswordMismatch]);
|
|
460
474
|
if (res.status === "error") {
|
|
461
|
-
return res.error;
|
|
475
|
+
return Result.error(res.error);
|
|
462
476
|
}
|
|
463
477
|
const result = await res.data.json();
|
|
464
|
-
return {
|
|
478
|
+
return Result.ok({
|
|
465
479
|
accessToken: result.access_token,
|
|
466
480
|
refreshToken: result.refresh_token,
|
|
467
|
-
};
|
|
481
|
+
});
|
|
468
482
|
}
|
|
469
483
|
async signUpWithCredential(email, password, emailVerificationRedirectUrl, session) {
|
|
470
484
|
const res = await this.sendClientRequestAndCatchKnownError("/auth/password/sign-up", {
|
|
@@ -479,13 +493,13 @@ export class StackClientInterface {
|
|
|
479
493
|
}),
|
|
480
494
|
}, session, [KnownErrors.UserEmailAlreadyExists, KnownErrors.PasswordRequirementsNotMet]);
|
|
481
495
|
if (res.status === "error") {
|
|
482
|
-
return res.error;
|
|
496
|
+
return Result.error(res.error);
|
|
483
497
|
}
|
|
484
498
|
const result = await res.data.json();
|
|
485
|
-
return {
|
|
499
|
+
return Result.ok({
|
|
486
500
|
accessToken: result.access_token,
|
|
487
501
|
refreshToken: result.refresh_token,
|
|
488
|
-
};
|
|
502
|
+
});
|
|
489
503
|
}
|
|
490
504
|
async signInWithMagicLink(code) {
|
|
491
505
|
const res = await this.sendClientRequestAndCatchKnownError("/auth/otp/sign-in", {
|
|
@@ -498,14 +512,14 @@ export class StackClientInterface {
|
|
|
498
512
|
}),
|
|
499
513
|
}, null, [KnownErrors.VerificationCodeError]);
|
|
500
514
|
if (res.status === "error") {
|
|
501
|
-
return res.error;
|
|
515
|
+
return Result.error(res.error);
|
|
502
516
|
}
|
|
503
517
|
const result = await res.data.json();
|
|
504
|
-
return {
|
|
518
|
+
return Result.ok({
|
|
505
519
|
accessToken: result.access_token,
|
|
506
520
|
refreshToken: result.refresh_token,
|
|
507
521
|
newUser: result.is_new_user,
|
|
508
|
-
};
|
|
522
|
+
});
|
|
509
523
|
}
|
|
510
524
|
async getOAuthUrl(options) {
|
|
511
525
|
const updatedRedirectUrl = new URL(options.redirectUrl);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CrudTypeOf } from "../../crud";
|
|
2
2
|
export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
3
3
|
clientReadSchema: import("yup").ObjectSchema<({
|
|
4
|
+
primary_email: string | null;
|
|
4
5
|
id: string;
|
|
5
6
|
display_name: string | null;
|
|
6
7
|
oauth_providers: {
|
|
@@ -8,7 +9,6 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
|
|
|
8
9
|
id: string;
|
|
9
10
|
account_id: string;
|
|
10
11
|
}[];
|
|
11
|
-
primary_email: string | null;
|
|
12
12
|
profile_image_url: string | null;
|
|
13
13
|
client_metadata: {} | null;
|
|
14
14
|
client_read_only_metadata: {} | null;
|
|
@@ -30,7 +30,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
|
|
|
30
30
|
} | {
|
|
31
31
|
type: "oauth";
|
|
32
32
|
provider: {
|
|
33
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
33
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
34
34
|
id: string;
|
|
35
35
|
provider_user_id: string;
|
|
36
36
|
};
|
|
@@ -38,7 +38,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
|
|
|
38
38
|
connected_accounts: {
|
|
39
39
|
type: "oauth";
|
|
40
40
|
provider: {
|
|
41
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
41
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
42
42
|
id: string;
|
|
43
43
|
provider_user_id: string;
|
|
44
44
|
};
|
|
@@ -114,7 +114,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
|
|
|
114
114
|
} | {
|
|
115
115
|
type: "oauth";
|
|
116
116
|
provider: {
|
|
117
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
117
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
118
118
|
id: string;
|
|
119
119
|
provider_user_id: string;
|
|
120
120
|
};
|
|
@@ -122,7 +122,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
|
|
|
122
122
|
connected_accounts: {
|
|
123
123
|
type: "oauth";
|
|
124
124
|
provider: {
|
|
125
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
125
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
126
126
|
id: string;
|
|
127
127
|
provider_user_id: string;
|
|
128
128
|
};
|
|
@@ -20,11 +20,11 @@ export declare const projectsCrudAdminReadSchema: import("yup").ObjectSchema<{
|
|
|
20
20
|
facebook_config_id?: string | undefined;
|
|
21
21
|
microsoft_tenant_id?: string | undefined;
|
|
22
22
|
type: NonNullable<"shared" | "standard" | undefined>;
|
|
23
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
23
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
24
24
|
enabled: NonNullable<boolean | undefined>;
|
|
25
25
|
}[];
|
|
26
26
|
enabled_oauth_providers: {
|
|
27
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
27
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
28
28
|
}[];
|
|
29
29
|
domains: {
|
|
30
30
|
domain: string;
|
|
@@ -89,7 +89,7 @@ export declare const projectsCrudClientReadSchema: import("yup").ObjectSchema<{
|
|
|
89
89
|
client_team_creation_enabled: NonNullable<boolean | undefined>;
|
|
90
90
|
client_user_deletion_enabled: NonNullable<boolean | undefined>;
|
|
91
91
|
enabled_oauth_providers: {
|
|
92
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
92
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
93
93
|
}[];
|
|
94
94
|
};
|
|
95
95
|
}, import("yup").AnyObject, {
|
|
@@ -121,7 +121,7 @@ export declare const projectsCrudAdminUpdateSchema: import("yup").ObjectSchema<{
|
|
|
121
121
|
facebook_config_id?: string | undefined;
|
|
122
122
|
microsoft_tenant_id?: string | undefined;
|
|
123
123
|
type: NonNullable<"shared" | "standard" | undefined>;
|
|
124
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
124
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
125
125
|
enabled: NonNullable<boolean | undefined>;
|
|
126
126
|
}[] | undefined;
|
|
127
127
|
domains?: {
|
|
@@ -168,7 +168,7 @@ export declare const projectsCrudAdminCreateSchema: import("yup").ObjectSchema<{
|
|
|
168
168
|
facebook_config_id?: string | undefined;
|
|
169
169
|
microsoft_tenant_id?: string | undefined;
|
|
170
170
|
type: NonNullable<"shared" | "standard" | undefined>;
|
|
171
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
171
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
172
172
|
enabled: NonNullable<boolean | undefined>;
|
|
173
173
|
}[] | undefined;
|
|
174
174
|
domains?: {
|
|
@@ -212,7 +212,7 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
212
212
|
client_team_creation_enabled: NonNullable<boolean | undefined>;
|
|
213
213
|
client_user_deletion_enabled: NonNullable<boolean | undefined>;
|
|
214
214
|
enabled_oauth_providers: {
|
|
215
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
215
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
216
216
|
}[];
|
|
217
217
|
};
|
|
218
218
|
}, import("yup").AnyObject, {
|
|
@@ -248,11 +248,11 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
248
248
|
facebook_config_id?: string | undefined;
|
|
249
249
|
microsoft_tenant_id?: string | undefined;
|
|
250
250
|
type: NonNullable<"shared" | "standard" | undefined>;
|
|
251
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
251
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
252
252
|
enabled: NonNullable<boolean | undefined>;
|
|
253
253
|
}[];
|
|
254
254
|
enabled_oauth_providers: {
|
|
255
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
255
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
256
256
|
}[];
|
|
257
257
|
domains: {
|
|
258
258
|
domain: string;
|
|
@@ -324,7 +324,7 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
324
324
|
facebook_config_id?: string | undefined;
|
|
325
325
|
microsoft_tenant_id?: string | undefined;
|
|
326
326
|
type: NonNullable<"shared" | "standard" | undefined>;
|
|
327
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
327
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
328
328
|
enabled: NonNullable<boolean | undefined>;
|
|
329
329
|
}[] | undefined;
|
|
330
330
|
domains?: {
|
|
@@ -401,11 +401,11 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
|
|
|
401
401
|
facebook_config_id?: string | undefined;
|
|
402
402
|
microsoft_tenant_id?: string | undefined;
|
|
403
403
|
type: NonNullable<"shared" | "standard" | undefined>;
|
|
404
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
404
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
405
405
|
enabled: NonNullable<boolean | undefined>;
|
|
406
406
|
}[];
|
|
407
407
|
enabled_oauth_providers: {
|
|
408
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
408
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
409
409
|
}[];
|
|
410
410
|
domains: {
|
|
411
411
|
domain: string;
|
|
@@ -477,7 +477,7 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
|
|
|
477
477
|
facebook_config_id?: string | undefined;
|
|
478
478
|
microsoft_tenant_id?: string | undefined;
|
|
479
479
|
type: NonNullable<"shared" | "standard" | undefined>;
|
|
480
|
-
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
480
|
+
id: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
481
481
|
enabled: NonNullable<boolean | undefined>;
|
|
482
482
|
}[] | undefined;
|
|
483
483
|
domains?: {
|
|
@@ -17,6 +17,7 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
|
|
|
17
17
|
profile_image_url: string | null;
|
|
18
18
|
} & {
|
|
19
19
|
user: {
|
|
20
|
+
primary_email: string | null;
|
|
20
21
|
id: string;
|
|
21
22
|
display_name: string | null;
|
|
22
23
|
oauth_providers: {
|
|
@@ -24,7 +25,6 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
|
|
|
24
25
|
id: string;
|
|
25
26
|
account_id: string;
|
|
26
27
|
}[];
|
|
27
|
-
primary_email: string | null;
|
|
28
28
|
profile_image_url: string | null;
|
|
29
29
|
client_metadata: {} | null;
|
|
30
30
|
client_read_only_metadata: {} | null;
|
|
@@ -56,7 +56,7 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
|
|
|
56
56
|
} | {
|
|
57
57
|
type: "oauth";
|
|
58
58
|
provider: {
|
|
59
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
59
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
60
60
|
id: string;
|
|
61
61
|
provider_user_id: string;
|
|
62
62
|
};
|
|
@@ -64,7 +64,7 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
|
|
|
64
64
|
connected_accounts: {
|
|
65
65
|
type: "oauth";
|
|
66
66
|
provider: {
|
|
67
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
67
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
68
68
|
id: string;
|
|
69
69
|
provider_user_id: string;
|
|
70
70
|
};
|
|
@@ -131,6 +131,7 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
|
|
|
131
131
|
profile_image_url: string | null;
|
|
132
132
|
} & {
|
|
133
133
|
user: {
|
|
134
|
+
primary_email: string | null;
|
|
134
135
|
id: string;
|
|
135
136
|
display_name: string | null;
|
|
136
137
|
oauth_providers: {
|
|
@@ -138,7 +139,6 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
|
|
|
138
139
|
id: string;
|
|
139
140
|
account_id: string;
|
|
140
141
|
}[];
|
|
141
|
-
primary_email: string | null;
|
|
142
142
|
profile_image_url: string | null;
|
|
143
143
|
client_metadata: {} | null;
|
|
144
144
|
client_read_only_metadata: {} | null;
|
|
@@ -170,7 +170,7 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
|
|
|
170
170
|
} | {
|
|
171
171
|
type: "oauth";
|
|
172
172
|
provider: {
|
|
173
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
173
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
174
174
|
id: string;
|
|
175
175
|
provider_user_id: string;
|
|
176
176
|
};
|
|
@@ -178,7 +178,7 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
|
|
|
178
178
|
connected_accounts: {
|
|
179
179
|
type: "oauth";
|
|
180
180
|
provider: {
|
|
181
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
181
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
182
182
|
id: string;
|
|
183
183
|
provider_user_id: string;
|
|
184
184
|
};
|
|
@@ -61,7 +61,7 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
|
|
|
61
61
|
} | {
|
|
62
62
|
type: "oauth";
|
|
63
63
|
provider: {
|
|
64
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
64
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
65
65
|
id: string;
|
|
66
66
|
provider_user_id: string;
|
|
67
67
|
};
|
|
@@ -69,7 +69,7 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
|
|
|
69
69
|
connected_accounts: {
|
|
70
70
|
type: "oauth";
|
|
71
71
|
provider: {
|
|
72
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
72
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
73
73
|
id: string;
|
|
74
74
|
provider_user_id: string;
|
|
75
75
|
};
|
|
@@ -107,9 +107,9 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
|
|
|
107
107
|
last_active_at_millis: undefined;
|
|
108
108
|
}, "">;
|
|
109
109
|
export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
|
|
110
|
+
primary_email: string | null | undefined;
|
|
110
111
|
password: string | null | undefined;
|
|
111
112
|
display_name: string | null | undefined;
|
|
112
|
-
primary_email: string | null | undefined;
|
|
113
113
|
profile_image_url: string | null | undefined;
|
|
114
114
|
client_metadata: {} | null | undefined;
|
|
115
115
|
client_read_only_metadata: {} | null | undefined;
|
|
@@ -119,8 +119,8 @@ export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
|
|
|
119
119
|
totp_secret_base64: string | null | undefined;
|
|
120
120
|
} & {
|
|
121
121
|
oauth_providers: {
|
|
122
|
-
id: string;
|
|
123
122
|
email: string | null;
|
|
123
|
+
id: string;
|
|
124
124
|
account_id: string;
|
|
125
125
|
}[] | undefined;
|
|
126
126
|
}, import("yup").AnyObject, {
|
|
@@ -176,7 +176,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
176
176
|
} | {
|
|
177
177
|
type: "oauth";
|
|
178
178
|
provider: {
|
|
179
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
179
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
180
180
|
id: string;
|
|
181
181
|
provider_user_id: string;
|
|
182
182
|
};
|
|
@@ -184,7 +184,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
184
184
|
connected_accounts: {
|
|
185
185
|
type: "oauth";
|
|
186
186
|
provider: {
|
|
187
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
187
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
188
188
|
id: string;
|
|
189
189
|
provider_user_id: string;
|
|
190
190
|
};
|
|
@@ -247,9 +247,9 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
247
247
|
selected_team_id: undefined;
|
|
248
248
|
}, "">;
|
|
249
249
|
serverCreateSchema: import("yup").ObjectSchema<{
|
|
250
|
+
primary_email: string | null | undefined;
|
|
250
251
|
password: string | null | undefined;
|
|
251
252
|
display_name: string | null | undefined;
|
|
252
|
-
primary_email: string | null | undefined;
|
|
253
253
|
profile_image_url: string | null | undefined;
|
|
254
254
|
client_metadata: {} | null | undefined;
|
|
255
255
|
client_read_only_metadata: {} | null | undefined;
|
|
@@ -259,8 +259,8 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
|
|
|
259
259
|
totp_secret_base64: string | null | undefined;
|
|
260
260
|
} & {
|
|
261
261
|
oauth_providers: {
|
|
262
|
-
id: string;
|
|
263
262
|
email: string | null;
|
|
263
|
+
id: string;
|
|
264
264
|
account_id: string;
|
|
265
265
|
}[] | undefined;
|
|
266
266
|
}, import("yup").AnyObject, {
|
|
@@ -346,7 +346,7 @@ export declare const userCreatedWebhookEvent: {
|
|
|
346
346
|
} | {
|
|
347
347
|
type: "oauth";
|
|
348
348
|
provider: {
|
|
349
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
349
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
350
350
|
id: string;
|
|
351
351
|
provider_user_id: string;
|
|
352
352
|
};
|
|
@@ -354,7 +354,7 @@ export declare const userCreatedWebhookEvent: {
|
|
|
354
354
|
connected_accounts: {
|
|
355
355
|
type: "oauth";
|
|
356
356
|
provider: {
|
|
357
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
357
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
358
358
|
id: string;
|
|
359
359
|
provider_user_id: string;
|
|
360
360
|
};
|
|
@@ -436,7 +436,7 @@ export declare const userUpdatedWebhookEvent: {
|
|
|
436
436
|
} | {
|
|
437
437
|
type: "oauth";
|
|
438
438
|
provider: {
|
|
439
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
439
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
440
440
|
id: string;
|
|
441
441
|
provider_user_id: string;
|
|
442
442
|
};
|
|
@@ -444,7 +444,7 @@ export declare const userUpdatedWebhookEvent: {
|
|
|
444
444
|
connected_accounts: {
|
|
445
445
|
type: "oauth";
|
|
446
446
|
provider: {
|
|
447
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
447
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
448
448
|
id: string;
|
|
449
449
|
provider_user_id: string;
|
|
450
450
|
};
|
|
@@ -47,7 +47,7 @@ export declare const webhookEvents: readonly [{
|
|
|
47
47
|
} | {
|
|
48
48
|
type: "oauth";
|
|
49
49
|
provider: {
|
|
50
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
50
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
51
51
|
id: string;
|
|
52
52
|
provider_user_id: string;
|
|
53
53
|
};
|
|
@@ -55,7 +55,7 @@ export declare const webhookEvents: readonly [{
|
|
|
55
55
|
connected_accounts: {
|
|
56
56
|
type: "oauth";
|
|
57
57
|
provider: {
|
|
58
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
58
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
59
59
|
id: string;
|
|
60
60
|
provider_user_id: string;
|
|
61
61
|
};
|
|
@@ -136,7 +136,7 @@ export declare const webhookEvents: readonly [{
|
|
|
136
136
|
} | {
|
|
137
137
|
type: "oauth";
|
|
138
138
|
provider: {
|
|
139
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
139
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
140
140
|
id: string;
|
|
141
141
|
provider_user_id: string;
|
|
142
142
|
};
|
|
@@ -144,7 +144,7 @@ export declare const webhookEvents: readonly [{
|
|
|
144
144
|
connected_accounts: {
|
|
145
145
|
type: "oauth";
|
|
146
146
|
provider: {
|
|
147
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
147
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
148
148
|
id: string;
|
|
149
149
|
provider_user_id: string;
|
|
150
150
|
};
|
package/dist/known-errors.d.ts
CHANGED
|
@@ -291,6 +291,11 @@ export declare const KnownErrors: {
|
|
|
291
291
|
} & KnownErrorBrand<"VERIFICATION_CODE_ALREADY_USED">, []> & {
|
|
292
292
|
errorCode: "VERIFICATION_CODE_ALREADY_USED";
|
|
293
293
|
};
|
|
294
|
+
VerificationCodeMaxAttemptsReached: KnownErrorConstructor<KnownError & KnownErrorBrand<"VERIFICATION_ERROR"> & {
|
|
295
|
+
constructorArgs: [statusCode: number, humanReadableMessage: string, details?: Json | undefined];
|
|
296
|
+
} & KnownErrorBrand<"VERIFICATION_CODE_MAX_ATTEMPTS_REACHED">, []> & {
|
|
297
|
+
errorCode: "VERIFICATION_CODE_MAX_ATTEMPTS_REACHED";
|
|
298
|
+
};
|
|
294
299
|
PasswordConfirmationMismatch: KnownErrorConstructor<KnownError & KnownErrorBrand<"PASSWORD_CONFIRMATION_MISMATCH">, []> & {
|
|
295
300
|
errorCode: "PASSWORD_CONFIRMATION_MISMATCH";
|
|
296
301
|
};
|
|
@@ -375,5 +380,8 @@ export declare const KnownErrors: {
|
|
|
375
380
|
TeamPermissionNotFound: KnownErrorConstructor<KnownError & KnownErrorBrand<"TEAM_PERMISSION_NOT_FOUND">, [any, any, any]> & {
|
|
376
381
|
errorCode: "TEAM_PERMISSION_NOT_FOUND";
|
|
377
382
|
};
|
|
383
|
+
OAuthProviderAccessDenied: KnownErrorConstructor<KnownError & KnownErrorBrand<"OAUTH_PROVIDER_ACCESS_DENIED">, []> & {
|
|
384
|
+
errorCode: "OAUTH_PROVIDER_ACCESS_DENIED";
|
|
385
|
+
};
|
|
378
386
|
};
|
|
379
387
|
export {};
|
package/dist/known-errors.js
CHANGED
|
@@ -372,6 +372,10 @@ const VerificationCodeAlreadyUsed = createKnownErrorConstructor(VerificationCode
|
|
|
372
372
|
400,
|
|
373
373
|
"The verification link has already been used.",
|
|
374
374
|
], () => []);
|
|
375
|
+
const VerificationCodeMaxAttemptsReached = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_MAX_ATTEMPTS_REACHED", () => [
|
|
376
|
+
400,
|
|
377
|
+
"The verification code nonce has reached the maximum number of attempts. This code is not valid anymore.",
|
|
378
|
+
], () => []);
|
|
375
379
|
const PasswordConfirmationMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_CONFIRMATION_MISMATCH", () => [
|
|
376
380
|
400,
|
|
377
381
|
"Passwords do not match.",
|
|
@@ -530,6 +534,10 @@ const InvalidAuthorizationCode = createKnownErrorConstructor(KnownError, "INVALI
|
|
|
530
534
|
400,
|
|
531
535
|
"The given authorization code is invalid.",
|
|
532
536
|
], () => []);
|
|
537
|
+
const OAuthProviderAccessDenied = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_ACCESS_DENIED", () => [
|
|
538
|
+
400,
|
|
539
|
+
"The OAuth provider denied access to the user.",
|
|
540
|
+
], () => []);
|
|
533
541
|
export const KnownErrors = {
|
|
534
542
|
UnsupportedError,
|
|
535
543
|
BodyParsingError,
|
|
@@ -588,6 +596,7 @@ export const KnownErrors = {
|
|
|
588
596
|
VerificationCodeNotFound,
|
|
589
597
|
VerificationCodeExpired,
|
|
590
598
|
VerificationCodeAlreadyUsed,
|
|
599
|
+
VerificationCodeMaxAttemptsReached,
|
|
591
600
|
PasswordConfirmationMismatch,
|
|
592
601
|
EmailAlreadyVerified,
|
|
593
602
|
EmailNotAssociatedWithUser,
|
|
@@ -616,6 +625,7 @@ export const KnownErrors = {
|
|
|
616
625
|
InvalidStandardOAuthProviderId,
|
|
617
626
|
InvalidAuthorizationCode,
|
|
618
627
|
TeamPermissionNotFound,
|
|
628
|
+
OAuthProviderAccessDenied,
|
|
619
629
|
};
|
|
620
630
|
// ensure that all known error codes are unique
|
|
621
631
|
const knownErrorCodes = new Set();
|
package/dist/schema-fields.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as yup from "yup";
|
|
2
|
+
export declare function yupValidate<S extends yup.ISchema<any>>(schema: S, obj: unknown, options?: yup.ValidateOptions & {
|
|
3
|
+
currentUserId?: string | null;
|
|
4
|
+
}): Promise<yup.InferType<S>>;
|
|
2
5
|
declare const StackAdaptSentinel: unique symbol;
|
|
3
6
|
export type StackAdaptSentinel = typeof StackAdaptSentinel;
|
|
4
7
|
export declare function yupString<A extends string, B extends yup.Maybe<yup.AnyObject> = yup.AnyObject>(...args: Parameters<typeof yup.string<A, B>>): yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
|
@@ -40,7 +43,7 @@ export declare const projectClientTeamCreationEnabledSchema: yup.BooleanSchema<b
|
|
|
40
43
|
export declare const projectClientUserDeletionEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
|
|
41
44
|
export declare const projectSignUpEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
|
|
42
45
|
export declare const projectCredentialEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
|
|
43
|
-
export declare const oauthIdSchema: yup.StringSchema<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined, yup.AnyObject, undefined, "">;
|
|
46
|
+
export declare const oauthIdSchema: yup.StringSchema<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined, yup.AnyObject, undefined, "">;
|
|
44
47
|
export declare const oauthEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
|
|
45
48
|
export declare const oauthTypeSchema: yup.StringSchema<"shared" | "standard" | undefined, yup.AnyObject, undefined, "">;
|
|
46
49
|
export declare const oauthClientIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
|
|
@@ -71,7 +74,7 @@ export declare const userClientReadOnlyMetadataSchema: yup.MixedSchema<{} | null
|
|
|
71
74
|
export declare const userServerMetadataSchema: yup.MixedSchema<{} | null, yup.AnyObject, undefined, "">;
|
|
72
75
|
export declare const userOAuthProviderSchema: yup.ObjectSchema<{
|
|
73
76
|
id: string;
|
|
74
|
-
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | undefined>;
|
|
77
|
+
type: NonNullable<"google" | "github" | "microsoft" | "spotify" | "facebook" | "discord" | "gitlab" | "bitbucket" | "linkedin" | "apple" | "x" | undefined>;
|
|
75
78
|
provider_user_id: string;
|
|
76
79
|
}, yup.AnyObject, {
|
|
77
80
|
id: undefined;
|
package/dist/schema-fields.js
CHANGED
|
@@ -1,8 +1,58 @@
|
|
|
1
1
|
import * as yup from "yup";
|
|
2
|
+
import { KnownErrors } from ".";
|
|
2
3
|
import { isBase64 } from "./utils/bytes";
|
|
3
4
|
import { StackAssertionError } from "./utils/errors";
|
|
4
5
|
import { allProviders } from "./utils/oauth";
|
|
6
|
+
import { deepPlainClone, omit } from "./utils/objects";
|
|
5
7
|
import { isUuid } from "./utils/uuids";
|
|
8
|
+
export async function yupValidate(schema, obj, options) {
|
|
9
|
+
try {
|
|
10
|
+
return await schema.validate(obj, {
|
|
11
|
+
...omit(options ?? {}, ['currentUserId']),
|
|
12
|
+
context: {
|
|
13
|
+
...options?.context,
|
|
14
|
+
stackAllowUserIdMe: options?.currentUserId !== undefined,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error instanceof ReplaceFieldWithOwnUserId) {
|
|
20
|
+
const currentUserId = options?.currentUserId;
|
|
21
|
+
if (!currentUserId)
|
|
22
|
+
throw new KnownErrors.CannotGetOwnUserWithoutUser();
|
|
23
|
+
// parse yup path
|
|
24
|
+
let pathRemaining = error.path;
|
|
25
|
+
const fieldPath = [];
|
|
26
|
+
while (pathRemaining.length > 0) {
|
|
27
|
+
if (pathRemaining.startsWith("[")) {
|
|
28
|
+
const index = pathRemaining.indexOf("]");
|
|
29
|
+
if (index < 0)
|
|
30
|
+
throw new StackAssertionError("Invalid path");
|
|
31
|
+
fieldPath.push(JSON.parse(pathRemaining.slice(1, index)));
|
|
32
|
+
pathRemaining = pathRemaining.slice(index + 1);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
let dotIndex = pathRemaining.indexOf(".");
|
|
36
|
+
if (dotIndex === -1)
|
|
37
|
+
dotIndex = pathRemaining.length;
|
|
38
|
+
fieldPath.push(pathRemaining.slice(0, dotIndex));
|
|
39
|
+
pathRemaining = pathRemaining.slice(dotIndex + 1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const newObj = deepPlainClone(obj);
|
|
43
|
+
let it = newObj;
|
|
44
|
+
for (const field of fieldPath.slice(0, -1)) {
|
|
45
|
+
if (!Object.prototype.hasOwnProperty.call(it, field)) {
|
|
46
|
+
throw new StackAssertionError(`Segment ${field} of path ${error.path} not found in object`);
|
|
47
|
+
}
|
|
48
|
+
it = it[field];
|
|
49
|
+
}
|
|
50
|
+
it[fieldPath[fieldPath.length - 1]] = currentUserId;
|
|
51
|
+
return await yupValidate(schema, newObj, options);
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
6
56
|
const _idDescription = (identify) => `The unique identifier of this ${identify}`;
|
|
7
57
|
const _displayNameDescription = (identify) => `Human-readable ${identify} display name. This is not a unique identifier.`;
|
|
8
58
|
const _clientMetaDataDescription = (identify) => `Client metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client.`;
|
|
@@ -82,7 +132,10 @@ export function yupUnion(...args) {
|
|
|
82
132
|
errors.push(e);
|
|
83
133
|
}
|
|
84
134
|
}
|
|
85
|
-
|
|
135
|
+
return context.createError({
|
|
136
|
+
message: `${context.path} is not matched by any of the provided schemas:\n${errors.map((e, i) => '\tSchema ' + i + ": \n\t\t" + e.errors.join('\n\t\t')).join('\n')}`,
|
|
137
|
+
path: context.path,
|
|
138
|
+
});
|
|
86
139
|
});
|
|
87
140
|
}
|
|
88
141
|
// Common
|
|
@@ -185,6 +238,10 @@ export const userIdOrMeSchema = yupString().uuid().transform(v => {
|
|
|
185
238
|
else
|
|
186
239
|
return v;
|
|
187
240
|
}).test((v, context) => {
|
|
241
|
+
if (!("stackAllowUserIdMe" in (context.options.context ?? {})))
|
|
242
|
+
throw new StackAssertionError('userIdOrMeSchema is not allowed in this context. Make sure you\'re using yupValidate from schema-fields.ts to validate, instead of schema.validate(...).');
|
|
243
|
+
if (!context.options.context?.stackAllowUserIdMe)
|
|
244
|
+
throw new StackAssertionError('userIdOrMeSchema is not allowed in this context. Make sure you\'re passing in the currentUserId option in yupValidate.');
|
|
188
245
|
if (v === userIdMeSentinelUuid)
|
|
189
246
|
throw new ReplaceFieldWithOwnUserId(context.path);
|
|
190
247
|
return true;
|
|
@@ -207,8 +264,8 @@ export const userOAuthProviderSchema = yupObject({
|
|
|
207
264
|
export const userLastActiveAtMillisSchema = yupNumber().nullable().meta({ openapiField: { description: _lastActiveAtMillisDescription, exampleValue: 1630000000000 } });
|
|
208
265
|
// Auth
|
|
209
266
|
export const signInEmailSchema = emailSchema.meta({ openapiField: { description: 'The email to sign in with.', exampleValue: 'johndoe@example.com' } });
|
|
210
|
-
export const emailOtpSignInCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct the magic link from. A query
|
|
211
|
-
export const emailVerificationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct a verification link for the verification e-mail. A query
|
|
267
|
+
export const emailOtpSignInCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct the magic link from. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/auth/otp/sign-in` endpoint.', exampleValue: 'https://example.com/handler/magic-link-callback' } });
|
|
268
|
+
export const emailVerificationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct a verification link for the verification e-mail. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/contact-channels/verify` endpoint.', exampleValue: 'https://example.com/handler/email-verification' } });
|
|
212
269
|
export const accessTokenResponseSchema = yupString().meta({ openapiField: { description: 'Short-lived access token that can be used to authenticate the user', exampleValue: 'eyJhmMiJB2TO...diI4QT' } });
|
|
213
270
|
export const refreshTokenResponseSchema = yupString().meta({ openapiField: { description: 'Long-lived refresh token that can be used to obtain a new access token', exampleValue: 'i8ns3aq2...14y' } });
|
|
214
271
|
export const signInResponseSchema = yupObject({
|
|
@@ -249,8 +306,8 @@ export const teamClientMetadataSchema = jsonSchema.meta({ openapiField: { descri
|
|
|
249
306
|
export const teamClientReadOnlyMetadataSchema = jsonSchema.meta({ openapiField: { description: _clientReadOnlyMetaDataDescription('team'), exampleValue: { key: 'value' } } });
|
|
250
307
|
export const teamServerMetadataSchema = jsonSchema.meta({ openapiField: { description: _serverMetaDataDescription('team'), exampleValue: { key: 'value' } } });
|
|
251
308
|
export const teamCreatedAtMillisSchema = yupNumber().meta({ openapiField: { description: _createdAtMillisDescription('team'), exampleValue: 1630000000000 } });
|
|
252
|
-
export const teamInvitationEmailSchema = emailSchema.meta({ openapiField: { description: 'The email
|
|
253
|
-
export const teamInvitationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct
|
|
309
|
+
export const teamInvitationEmailSchema = emailSchema.meta({ openapiField: { description: 'The email of the user to invite.', exampleValue: 'johndoe@example.com' } });
|
|
310
|
+
export const teamInvitationCallbackUrlSchema = urlSchema.meta({ openapiField: { description: 'The base callback URL to construct an invite link with. A query parameter `code` with the verification code will be appended to it. The page should then make a request to the `/team-invitations/accept` endpoint.', exampleValue: 'https://example.com/handler/team-invitation' } });
|
|
254
311
|
// Team member profiles
|
|
255
312
|
export const teamMemberDisplayNameSchema = yupString().meta({ openapiField: { description: _displayNameDescription('team member') + ' Note that this is separate from the display_name of the user.', exampleValue: 'John Doe' } });
|
|
256
313
|
export const teamMemberProfileImageUrlSchema = urlSchema.max(1000000).meta({ openapiField: { description: _profileImageUrlDescription('team member'), exampleValue: 'https://example.com/image.jpg' } });
|
package/dist/utils/jwt.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare function getPublicJwkSet(): Promise<{
|
|
|
15
15
|
d: string;
|
|
16
16
|
x: string;
|
|
17
17
|
y: string;
|
|
18
|
-
}, "
|
|
18
|
+
}, "x" | "kty" | "crv" | "y">[];
|
|
19
19
|
}>;
|
|
20
20
|
export declare function encryptJWE(payload: any, expirationTime?: string): Promise<string>;
|
|
21
21
|
export declare function decryptJWE(jwt: string): Promise<jose.JWTPayload>;
|
package/dist/utils/jwt.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import elliptic from "elliptic";
|
|
1
2
|
import * as jose from "jose";
|
|
3
|
+
import { encodeBase64 } from "./bytes";
|
|
2
4
|
import { getEnvVariable } from "./env";
|
|
3
|
-
import elliptic from "elliptic";
|
|
4
5
|
import { globalVar } from "./globals";
|
|
5
|
-
import { encodeBase64 } from "./bytes";
|
|
6
6
|
import { pick } from "./objects";
|
|
7
7
|
const STACK_SERVER_SECRET = jose.base64url.decode(getEnvVariable("STACK_SERVER_SECRET"));
|
|
8
8
|
export async function signJWT(issuer, payload, expirationTime = "5m") {
|
package/dist/utils/oauth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const standardProviders: readonly ["google", "github", "microsoft", "spotify", "facebook", "discord", "gitlab", "bitbucket", "linkedin", "apple"];
|
|
1
|
+
export declare const standardProviders: readonly ["google", "github", "microsoft", "spotify", "facebook", "discord", "gitlab", "bitbucket", "linkedin", "apple", "x"];
|
|
2
2
|
export declare const sharedProviders: readonly ["google", "github", "microsoft", "spotify"];
|
|
3
|
-
export declare const allProviders: readonly ["google", "github", "microsoft", "spotify", "facebook", "discord", "gitlab", "bitbucket", "linkedin", "apple"];
|
|
3
|
+
export declare const allProviders: readonly ["google", "github", "microsoft", "spotify", "facebook", "discord", "gitlab", "bitbucket", "linkedin", "apple", "x"];
|
|
4
4
|
export type ProviderType = typeof allProviders[number];
|
|
5
5
|
export type StandardProviderType = typeof standardProviders[number];
|
|
6
6
|
export type SharedProviderType = typeof sharedProviders[number];
|
package/dist/utils/oauth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const standardProviders = ["google", "github", "microsoft", "spotify", "facebook", "discord", "gitlab", "bitbucket", "linkedin", "apple"];
|
|
1
|
+
export const standardProviders = ["google", "github", "microsoft", "spotify", "facebook", "discord", "gitlab", "bitbucket", "linkedin", "apple", "x"];
|
|
2
2
|
// No more shared providers should be added except for special cases
|
|
3
3
|
export const sharedProviders = ["google", "github", "microsoft", "spotify"];
|
|
4
4
|
export const allProviders = standardProviders;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackframe/stack-shared",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -36,13 +36,15 @@
|
|
|
36
36
|
"elliptic": "^6.5.7",
|
|
37
37
|
"jose": "^5.2.2",
|
|
38
38
|
"oauth4webapi": "^2.10.3",
|
|
39
|
+
"semver": "^7.6.3",
|
|
39
40
|
"uuid": "^9.0.1",
|
|
40
|
-
"@stackframe/stack-sc": "2.
|
|
41
|
+
"@stackframe/stack-sc": "2.6.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@types/bcrypt": "^5.0.2",
|
|
44
45
|
"@types/elliptic": "^6.4.18",
|
|
45
46
|
"@types/react": "^18.2.66",
|
|
47
|
+
"@types/semver": "^7.5.8",
|
|
46
48
|
"@types/uuid": "^9.0.8",
|
|
47
49
|
"next": "^14.1.0",
|
|
48
50
|
"react": "^18.2.0",
|