@stackframe/stack-shared 2.6.12 → 2.6.16

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,33 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.6.16
4
+
5
+ ### Patch Changes
6
+
7
+ - - list user pagination
8
+ - fixed visual glitches
9
+ - @stackframe/stack-sc@2.6.16
10
+
11
+ ## 2.6.15
12
+
13
+ ### Patch Changes
14
+
15
+ - Passkeys
16
+ - @stackframe/stack-sc@2.6.15
17
+
18
+ ## 2.6.14
19
+
20
+ ### Patch Changes
21
+
22
+ - @stackframe/stack-sc@2.6.14
23
+
24
+ ## 2.6.13
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated docs
29
+ - @stackframe/stack-sc@2.6.13
30
+
3
31
  ## 2.6.12
4
32
 
5
33
  ### Patch Changes
package/dist/crud.d.ts CHANGED
@@ -81,6 +81,9 @@ type InnerCrudTypeOf<S extends InnerCrudSchema> = (S['createSchema'] extends {}
81
81
  List: {
82
82
  items: yup.InferType<S['readSchema']>[];
83
83
  is_paginated: boolean;
84
+ pagination?: {
85
+ next_cursor: string | null;
86
+ };
84
87
  };
85
88
  } : {});
86
89
  export type CrudTypeOf<S extends CrudSchema> = {
@@ -1,6 +1,7 @@
1
1
  import { KnownErrors } from '../known-errors';
2
2
  import { AccessToken, InternalSession, RefreshToken } from '../sessions';
3
3
  import { ReadonlyJson } from '../utils/json';
4
+ import { AuthenticationResponseJSON, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, RegistrationResponseJSON } from '../utils/passkey';
4
5
  import { Result } from "../utils/results";
5
6
  import { ContactChannelsCrud } from './crud/contact-channels';
6
7
  import { CurrentUserCrud } from './crud/current-user';
@@ -73,12 +74,24 @@ export declare class StackClientInterface {
73
74
  }, session: InternalSession): Promise<KnownErrors["PasswordRequirementsNotMet"] | undefined>;
74
75
  verifyPasswordResetCode(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
75
76
  verifyEmail(code: string): Promise<Result<undefined, KnownErrors["VerificationCodeError"]>>;
77
+ initiatePasskeyRegistration(options: {}, session: InternalSession): Promise<Result<{
78
+ options_json: PublicKeyCredentialCreationOptionsJSON;
79
+ code: string;
80
+ }, KnownErrors[]>>;
81
+ registerPasskey(options: {
82
+ credential: RegistrationResponseJSON;
83
+ code: string;
84
+ }, session: InternalSession): Promise<Result<undefined, KnownErrors["PasskeyRegistrationFailed"]>>;
85
+ initiatePasskeyAuthentication(options: {}, session: InternalSession): Promise<Result<{
86
+ options_json: PublicKeyCredentialRequestOptionsJSON;
87
+ code: string;
88
+ }, KnownErrors[]>>;
76
89
  sendTeamInvitation(options: {
77
90
  email: string;
78
91
  teamId: string;
79
92
  callbackUrl: string;
80
93
  session: InternalSession | null;
81
- }): Promise<Result<undefined, KnownErrors["TeamPermissionRequired"]>>;
94
+ }): Promise<void>;
82
95
  acceptTeamInvitation<T extends 'use' | 'details' | 'check'>(options: {
83
96
  code: string;
84
97
  session: InternalSession;
@@ -104,6 +117,13 @@ export declare class StackClientInterface {
104
117
  accessToken: string;
105
118
  refreshToken: string;
106
119
  }, KnownErrors["VerificationCodeError"]>>;
120
+ signInWithPasskey(body: {
121
+ authentication_response: AuthenticationResponseJSON;
122
+ code: string;
123
+ }): Promise<Result<{
124
+ accessToken: string;
125
+ refreshToken: string;
126
+ }, KnownErrors["PasskeyAuthenticationFailed"]>>;
107
127
  getOAuthUrl(options: {
108
128
  provider: string;
109
129
  redirectUrl: string;
@@ -413,8 +413,47 @@ export class StackClientInterface {
413
413
  return Result.ok(undefined);
414
414
  }
415
415
  }
416
+ async initiatePasskeyRegistration(options, session) {
417
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/passkey/initiate-passkey-registration", {
418
+ method: "POST",
419
+ headers: {
420
+ "Content-Type": "application/json"
421
+ },
422
+ body: JSON.stringify(options),
423
+ }, session, []);
424
+ if (res.status === "error") {
425
+ return Result.error(res.error);
426
+ }
427
+ return Result.ok(await res.data.json());
428
+ }
429
+ async registerPasskey(options, session) {
430
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/passkey/register", {
431
+ method: "POST",
432
+ headers: {
433
+ "Content-Type": "application/json"
434
+ },
435
+ body: JSON.stringify(options),
436
+ }, session, [KnownErrors.PasskeyRegistrationFailed]);
437
+ if (res.status === "error") {
438
+ return Result.error(res.error);
439
+ }
440
+ return Result.ok(undefined);
441
+ }
442
+ async initiatePasskeyAuthentication(options, session) {
443
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/passkey/initiate-passkey-authentication", {
444
+ method: "POST",
445
+ headers: {
446
+ "Content-Type": "application/json"
447
+ },
448
+ body: JSON.stringify(options),
449
+ }, session, []);
450
+ if (res.status === "error") {
451
+ return Result.error(res.error);
452
+ }
453
+ return Result.ok(await res.data.json());
454
+ }
416
455
  async sendTeamInvitation(options) {
417
- const res = await this.sendClientRequestAndCatchKnownError("/team-invitations/send-code", {
456
+ await this.sendClientRequest("/team-invitations/send-code", {
418
457
  method: "POST",
419
458
  headers: {
420
459
  "Content-Type": "application/json"
@@ -424,13 +463,7 @@ export class StackClientInterface {
424
463
  team_id: options.teamId,
425
464
  callback_url: options.callbackUrl,
426
465
  }),
427
- }, options.session, [KnownErrors.TeamPermissionRequired]);
428
- if (res.status === "error") {
429
- return Result.error(res.error);
430
- }
431
- else {
432
- return Result.ok(undefined);
433
- }
466
+ }, options.session);
434
467
  }
435
468
  async acceptTeamInvitation(options) {
436
469
  const res = await this.sendClientRequestAndCatchKnownError(options.type === 'check' ?
@@ -533,6 +566,23 @@ export class StackClientInterface {
533
566
  newUser: result.is_new_user,
534
567
  });
535
568
  }
569
+ async signInWithPasskey(body) {
570
+ const res = await this.sendClientRequestAndCatchKnownError("/auth/passkey/sign-in", {
571
+ method: "POST",
572
+ headers: {
573
+ "Content-Type": "application/json"
574
+ },
575
+ body: JSON.stringify(body),
576
+ }, null, [KnownErrors.PasskeyAuthenticationFailed]);
577
+ if (res.status === "error") {
578
+ return Result.error(res.error);
579
+ }
580
+ const result = await res.data.json();
581
+ return Result.ok({
582
+ accessToken: result.access_token,
583
+ refreshToken: result.refresh_token,
584
+ });
585
+ }
536
586
  async getOAuthUrl(options) {
537
587
  const updatedRedirectUrl = new URL(options.redirectUrl);
538
588
  for (const key of ["code", "state"]) {
@@ -146,19 +146,29 @@ export declare const contactChannelsCrud: import("../../crud").CrudSchemaFromOpt
146
146
  }, "">;
147
147
  docs: {
148
148
  clientRead: {
149
- hidden: true;
149
+ summary: string;
150
+ description: string;
151
+ tags: string[];
150
152
  };
151
153
  clientCreate: {
152
- hidden: true;
154
+ summary: string;
155
+ description: string;
156
+ tags: string[];
153
157
  };
154
158
  clientUpdate: {
155
- hidden: true;
159
+ summary: string;
160
+ description: string;
161
+ tags: string[];
156
162
  };
157
163
  clientDelete: {
158
- hidden: true;
164
+ summary: string;
165
+ description: string;
166
+ tags: string[];
159
167
  };
160
168
  clientList: {
161
- hidden: true;
169
+ summary: string;
170
+ description: string;
171
+ tags: string[];
162
172
  };
163
173
  };
164
174
  }>;
@@ -1,38 +1,32 @@
1
1
  import { createCrud } from "../../crud";
2
- import { userIdOrMeSchema, userIdSchema, yupBoolean, yupMixed, yupObject, yupString } from "../../schema-fields";
3
- const contactChannelsTypes = ['email'];
4
- const type = yupString().oneOf(contactChannelsTypes);
5
- const value = yupString().when('type', {
6
- is: 'email',
7
- then: (schema) => schema.email(),
8
- });
2
+ import { contactChannelIdSchema, contactChannelIsPrimarySchema, contactChannelIsVerifiedSchema, contactChannelTypeSchema, contactChannelUsedForAuthSchema, contactChannelValueSchema, userIdOrMeSchema, userIdSchema, yupMixed, yupObject } from "../../schema-fields";
9
3
  export const contactChannelsClientReadSchema = yupObject({
10
4
  user_id: userIdSchema.required(),
11
- id: yupString().required(),
12
- value: value.required(),
13
- type: type.required(),
14
- used_for_auth: yupBoolean().required(),
15
- is_verified: yupBoolean().required(),
16
- is_primary: yupBoolean().required(),
5
+ id: contactChannelIdSchema.required(),
6
+ value: contactChannelValueSchema.required(),
7
+ type: contactChannelTypeSchema.required(),
8
+ used_for_auth: contactChannelUsedForAuthSchema.required(),
9
+ is_verified: contactChannelIsVerifiedSchema.required(),
10
+ is_primary: contactChannelIsPrimarySchema.required(),
17
11
  }).required();
18
12
  export const contactChannelsCrudClientUpdateSchema = yupObject({
19
- value: value.optional(),
20
- type: type.optional(),
21
- used_for_auth: yupBoolean().optional(),
22
- is_primary: yupBoolean().optional(),
13
+ value: contactChannelValueSchema.optional(),
14
+ type: contactChannelTypeSchema.optional(),
15
+ used_for_auth: contactChannelUsedForAuthSchema.optional(),
16
+ is_primary: contactChannelIsPrimarySchema.optional(),
23
17
  }).required();
24
18
  export const contactChannelsCrudServerUpdateSchema = contactChannelsCrudClientUpdateSchema.concat(yupObject({
25
- is_verified: yupBoolean().optional(),
19
+ is_verified: contactChannelIsVerifiedSchema.optional(),
26
20
  }));
27
21
  export const contactChannelsCrudClientCreateSchema = yupObject({
28
22
  user_id: userIdOrMeSchema.required(),
29
- value: value.required(),
30
- type: type.required(),
31
- used_for_auth: yupBoolean().required(),
32
- is_primary: yupBoolean().optional(),
23
+ value: contactChannelValueSchema.required(),
24
+ type: contactChannelTypeSchema.required(),
25
+ used_for_auth: contactChannelUsedForAuthSchema.required(),
26
+ is_primary: contactChannelIsPrimarySchema.optional(),
33
27
  }).required();
34
28
  export const contactChannelsCrudServerCreateSchema = contactChannelsCrudClientCreateSchema.concat(yupObject({
35
- is_verified: yupBoolean().optional(),
29
+ is_verified: contactChannelIsVerifiedSchema.optional(),
36
30
  }));
37
31
  export const contactChannelsCrudClientDeleteSchema = yupMixed();
38
32
  export const contactChannelsCrud = createCrud({
@@ -44,19 +38,29 @@ export const contactChannelsCrud = createCrud({
44
38
  serverCreateSchema: contactChannelsCrudServerCreateSchema,
45
39
  docs: {
46
40
  clientRead: {
47
- hidden: true,
41
+ summary: "Get a contact channel",
42
+ description: "",
43
+ tags: ["Contact Channels"],
48
44
  },
49
45
  clientCreate: {
50
- hidden: true,
46
+ summary: "Create a contact channel",
47
+ description: "",
48
+ tags: ["Contact Channels"],
51
49
  },
52
50
  clientUpdate: {
53
- hidden: true,
51
+ summary: "Update a contact channel",
52
+ description: "",
53
+ tags: ["Contact Channels"],
54
54
  },
55
55
  clientDelete: {
56
- hidden: true,
56
+ summary: "Delete a contact channel",
57
+ description: "",
58
+ tags: ["Contact Channels"],
57
59
  },
58
60
  clientList: {
59
- hidden: true,
61
+ summary: "List contact channels",
62
+ description: "",
63
+ tags: ["Contact Channels"],
60
64
  }
61
65
  }
62
66
  });
@@ -13,6 +13,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
13
13
  client_metadata: {} | null;
14
14
  client_read_only_metadata: {} | null;
15
15
  primary_email_verified: NonNullable<boolean | undefined>;
16
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
16
17
  otp_auth_enabled: NonNullable<boolean | undefined>;
17
18
  selected_team_id: string | null;
18
19
  signed_up_at_millis: number;
@@ -45,6 +46,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
45
46
  signed_up_at_millis: undefined;
46
47
  has_password: undefined;
47
48
  otp_auth_enabled: undefined;
49
+ passkey_auth_enabled: undefined;
48
50
  client_metadata: undefined;
49
51
  client_read_only_metadata: undefined;
50
52
  server_metadata: undefined;
@@ -73,6 +75,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
73
75
  signed_up_at_millis: number;
74
76
  has_password: NonNullable<boolean | undefined>;
75
77
  otp_auth_enabled: NonNullable<boolean | undefined>;
78
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
76
79
  client_metadata: {} | null;
77
80
  client_read_only_metadata: {} | null;
78
81
  server_metadata: {} | null;
@@ -104,6 +107,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
104
107
  signed_up_at_millis: undefined;
105
108
  has_password: undefined;
106
109
  otp_auth_enabled: undefined;
110
+ passkey_auth_enabled: undefined;
107
111
  client_metadata: undefined;
108
112
  client_read_only_metadata: undefined;
109
113
  server_metadata: undefined;
@@ -116,6 +120,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
116
120
  display_name: string | null | undefined;
117
121
  profile_image_url: string | null | undefined;
118
122
  client_metadata: {} | null | undefined;
123
+ passkey_auth_enabled: boolean | undefined;
119
124
  otp_auth_enabled: boolean | undefined;
120
125
  totp_secret_base64: string | null | undefined;
121
126
  selected_team_id: string | null | undefined;
@@ -128,6 +133,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
128
133
  primary_email: undefined;
129
134
  primary_email_verified: undefined;
130
135
  primary_email_auth_enabled: undefined;
136
+ passkey_auth_enabled: undefined;
131
137
  password: undefined;
132
138
  otp_auth_enabled: undefined;
133
139
  totp_secret_base64: undefined;
@@ -142,6 +148,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
142
148
  primary_email: string | null | undefined;
143
149
  primary_email_verified: boolean | undefined;
144
150
  primary_email_auth_enabled: boolean | undefined;
151
+ passkey_auth_enabled: boolean | undefined;
145
152
  password: string | null | undefined;
146
153
  otp_auth_enabled: boolean | undefined;
147
154
  totp_secret_base64: string | null | undefined;
@@ -155,6 +162,7 @@ export declare const currentUserCrud: import("../../crud").CrudSchemaFromOptions
155
162
  primary_email: undefined;
156
163
  primary_email_verified: undefined;
157
164
  primary_email_auth_enabled: undefined;
165
+ passkey_auth_enabled: undefined;
158
166
  password: undefined;
159
167
  otp_auth_enabled: undefined;
160
168
  totp_secret_base64: undefined;
@@ -9,6 +9,7 @@ const clientUpdateSchema = usersCrudServerUpdateSchema.pick([
9
9
  "selected_team_id",
10
10
  "totp_secret_base64",
11
11
  "otp_auth_enabled",
12
+ "passkey_auth_enabled",
12
13
  ]).required();
13
14
  const serverUpdateSchema = usersCrudServerUpdateSchema;
14
15
  const clientReadSchema = usersCrudServerReadSchema.pick([
@@ -26,6 +27,7 @@ const clientReadSchema = usersCrudServerReadSchema.pick([
26
27
  "selected_team_id",
27
28
  "requires_totp_mfa",
28
29
  "otp_auth_enabled",
30
+ "passkey_auth_enabled",
29
31
  ]).concat(yupObject({
30
32
  selected_team: teamsCrudClientReadSchema.nullable().defined(),
31
33
  })).nullable().defined(); // TODO: next-release: make required
@@ -12,6 +12,7 @@ export declare const projectsCrudAdminReadSchema: import("yup").ObjectSchema<{
12
12
  sign_up_enabled: NonNullable<boolean | undefined>;
13
13
  credential_enabled: NonNullable<boolean | undefined>;
14
14
  magic_link_enabled: NonNullable<boolean | undefined>;
15
+ passkey_enabled: NonNullable<boolean | undefined>;
15
16
  legacy_global_jwt_signing: NonNullable<boolean | undefined>;
16
17
  client_team_creation_enabled: NonNullable<boolean | undefined>;
17
18
  client_user_deletion_enabled: NonNullable<boolean | undefined>;
@@ -61,6 +62,7 @@ export declare const projectsCrudAdminReadSchema: import("yup").ObjectSchema<{
61
62
  sign_up_enabled: undefined;
62
63
  credential_enabled: undefined;
63
64
  magic_link_enabled: undefined;
65
+ passkey_enabled: undefined;
64
66
  legacy_global_jwt_signing: undefined;
65
67
  client_team_creation_enabled: undefined;
66
68
  client_user_deletion_enabled: undefined;
@@ -88,6 +90,7 @@ export declare const projectsCrudClientReadSchema: import("yup").ObjectSchema<{
88
90
  sign_up_enabled: NonNullable<boolean | undefined>;
89
91
  credential_enabled: NonNullable<boolean | undefined>;
90
92
  magic_link_enabled: NonNullable<boolean | undefined>;
93
+ passkey_enabled: NonNullable<boolean | undefined>;
91
94
  client_team_creation_enabled: NonNullable<boolean | undefined>;
92
95
  client_user_deletion_enabled: NonNullable<boolean | undefined>;
93
96
  enabled_oauth_providers: {
@@ -101,6 +104,7 @@ export declare const projectsCrudClientReadSchema: import("yup").ObjectSchema<{
101
104
  sign_up_enabled: undefined;
102
105
  credential_enabled: undefined;
103
106
  magic_link_enabled: undefined;
107
+ passkey_enabled: undefined;
104
108
  client_team_creation_enabled: undefined;
105
109
  client_user_deletion_enabled: undefined;
106
110
  enabled_oauth_providers: undefined;
@@ -115,6 +119,7 @@ export declare const projectsCrudAdminUpdateSchema: import("yup").ObjectSchema<{
115
119
  sign_up_enabled?: boolean | undefined;
116
120
  credential_enabled?: boolean | undefined;
117
121
  magic_link_enabled?: boolean | undefined;
122
+ passkey_enabled?: boolean | undefined;
118
123
  legacy_global_jwt_signing?: false | undefined;
119
124
  client_team_creation_enabled?: boolean | undefined;
120
125
  client_user_deletion_enabled?: boolean | undefined;
@@ -163,6 +168,7 @@ export declare const projectsCrudAdminCreateSchema: import("yup").ObjectSchema<{
163
168
  sign_up_enabled?: boolean | undefined;
164
169
  credential_enabled?: boolean | undefined;
165
170
  magic_link_enabled?: boolean | undefined;
171
+ passkey_enabled?: boolean | undefined;
166
172
  legacy_global_jwt_signing?: false | undefined;
167
173
  client_team_creation_enabled?: boolean | undefined;
168
174
  client_user_deletion_enabled?: boolean | undefined;
@@ -213,6 +219,7 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
213
219
  sign_up_enabled: NonNullable<boolean | undefined>;
214
220
  credential_enabled: NonNullable<boolean | undefined>;
215
221
  magic_link_enabled: NonNullable<boolean | undefined>;
222
+ passkey_enabled: NonNullable<boolean | undefined>;
216
223
  client_team_creation_enabled: NonNullable<boolean | undefined>;
217
224
  client_user_deletion_enabled: NonNullable<boolean | undefined>;
218
225
  enabled_oauth_providers: {
@@ -226,6 +233,7 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
226
233
  sign_up_enabled: undefined;
227
234
  credential_enabled: undefined;
228
235
  magic_link_enabled: undefined;
236
+ passkey_enabled: undefined;
229
237
  client_team_creation_enabled: undefined;
230
238
  client_user_deletion_enabled: undefined;
231
239
  enabled_oauth_providers: undefined;
@@ -244,6 +252,7 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
244
252
  sign_up_enabled: NonNullable<boolean | undefined>;
245
253
  credential_enabled: NonNullable<boolean | undefined>;
246
254
  magic_link_enabled: NonNullable<boolean | undefined>;
255
+ passkey_enabled: NonNullable<boolean | undefined>;
247
256
  legacy_global_jwt_signing: NonNullable<boolean | undefined>;
248
257
  client_team_creation_enabled: NonNullable<boolean | undefined>;
249
258
  client_user_deletion_enabled: NonNullable<boolean | undefined>;
@@ -293,6 +302,7 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
293
302
  sign_up_enabled: undefined;
294
303
  credential_enabled: undefined;
295
304
  magic_link_enabled: undefined;
305
+ passkey_enabled: undefined;
296
306
  legacy_global_jwt_signing: undefined;
297
307
  client_team_creation_enabled: undefined;
298
308
  client_user_deletion_enabled: undefined;
@@ -322,6 +332,7 @@ export declare const projectsCrud: import("../../crud").CrudSchemaFromOptions<{
322
332
  sign_up_enabled?: boolean | undefined;
323
333
  credential_enabled?: boolean | undefined;
324
334
  magic_link_enabled?: boolean | undefined;
335
+ passkey_enabled?: boolean | undefined;
325
336
  legacy_global_jwt_signing?: false | undefined;
326
337
  client_team_creation_enabled?: boolean | undefined;
327
338
  client_user_deletion_enabled?: boolean | undefined;
@@ -400,6 +411,7 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
400
411
  sign_up_enabled: NonNullable<boolean | undefined>;
401
412
  credential_enabled: NonNullable<boolean | undefined>;
402
413
  magic_link_enabled: NonNullable<boolean | undefined>;
414
+ passkey_enabled: NonNullable<boolean | undefined>;
403
415
  legacy_global_jwt_signing: NonNullable<boolean | undefined>;
404
416
  client_team_creation_enabled: NonNullable<boolean | undefined>;
405
417
  client_user_deletion_enabled: NonNullable<boolean | undefined>;
@@ -449,6 +461,7 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
449
461
  sign_up_enabled: undefined;
450
462
  credential_enabled: undefined;
451
463
  magic_link_enabled: undefined;
464
+ passkey_enabled: undefined;
452
465
  legacy_global_jwt_signing: undefined;
453
466
  client_team_creation_enabled: undefined;
454
467
  client_user_deletion_enabled: undefined;
@@ -478,6 +491,7 @@ export declare const internalProjectsCrud: import("../../crud").CrudSchemaFromOp
478
491
  sign_up_enabled?: boolean | undefined;
479
492
  credential_enabled?: boolean | undefined;
480
493
  magic_link_enabled?: boolean | undefined;
494
+ passkey_enabled?: boolean | undefined;
481
495
  legacy_global_jwt_signing?: false | undefined;
482
496
  client_team_creation_enabled?: boolean | undefined;
483
497
  client_user_deletion_enabled?: boolean | undefined;
@@ -43,12 +43,13 @@ export const projectsCrudAdminReadSchema = yupObject({
43
43
  sign_up_enabled: schemaFields.projectSignUpEnabledSchema.required(),
44
44
  credential_enabled: schemaFields.projectCredentialEnabledSchema.required(),
45
45
  magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.required(),
46
+ passkey_enabled: schemaFields.projectPasskeyEnabledSchema.required(),
46
47
  // TODO: remove this
47
48
  legacy_global_jwt_signing: schemaFields.yupBoolean().required(),
48
49
  client_team_creation_enabled: schemaFields.projectClientTeamCreationEnabledSchema.required(),
49
50
  client_user_deletion_enabled: schemaFields.projectClientUserDeletionEnabledSchema.required(),
50
51
  oauth_providers: yupArray(oauthProviderSchema.required()).required(),
51
- enabled_oauth_providers: yupArray(enabledOAuthProviderSchema.required()).required(),
52
+ enabled_oauth_providers: yupArray(enabledOAuthProviderSchema.required()).required().meta({ openapiField: { hidden: true } }),
52
53
  domains: yupArray(domainSchema.required()).required(),
53
54
  email_config: emailConfigSchema.required(),
54
55
  create_team_on_sign_up: schemaFields.projectCreateTeamOnSignUpSchema.required(),
@@ -63,9 +64,10 @@ export const projectsCrudClientReadSchema = yupObject({
63
64
  sign_up_enabled: schemaFields.projectSignUpEnabledSchema.required(),
64
65
  credential_enabled: schemaFields.projectCredentialEnabledSchema.required(),
65
66
  magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.required(),
67
+ passkey_enabled: schemaFields.projectPasskeyEnabledSchema.required(),
66
68
  client_team_creation_enabled: schemaFields.projectClientTeamCreationEnabledSchema.required(),
67
69
  client_user_deletion_enabled: schemaFields.projectClientUserDeletionEnabledSchema.required(),
68
- enabled_oauth_providers: yupArray(enabledOAuthProviderSchema.required()).required(),
70
+ enabled_oauth_providers: yupArray(enabledOAuthProviderSchema.required()).required().meta({ openapiField: { hidden: true } }),
69
71
  }).required(),
70
72
  }).required();
71
73
  export const projectsCrudAdminUpdateSchema = yupObject({
@@ -76,6 +78,7 @@ export const projectsCrudAdminUpdateSchema = yupObject({
76
78
  sign_up_enabled: schemaFields.projectSignUpEnabledSchema.optional(),
77
79
  credential_enabled: schemaFields.projectCredentialEnabledSchema.optional(),
78
80
  magic_link_enabled: schemaFields.projectMagicLinkEnabledSchema.optional(),
81
+ passkey_enabled: schemaFields.projectPasskeyEnabledSchema.optional(),
79
82
  client_team_creation_enabled: schemaFields.projectClientTeamCreationEnabledSchema.optional(),
80
83
  client_user_deletion_enabled: schemaFields.projectClientUserDeletionEnabledSchema.optional(),
81
84
  legacy_global_jwt_signing: schemaFields.yupBoolean().isFalse().optional(),
@@ -31,6 +31,7 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
31
31
  server_metadata: {} | null;
32
32
  primary_email_verified: NonNullable<boolean | undefined>;
33
33
  primary_email_auth_enabled: NonNullable<boolean | undefined>;
34
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
34
35
  otp_auth_enabled: NonNullable<boolean | undefined>;
35
36
  selected_team_id: string | null;
36
37
  selected_team: {
@@ -73,6 +74,7 @@ export declare const teamMemberProfilesCrudServerReadSchema: import("yup").Objec
73
74
  signed_up_at_millis: undefined;
74
75
  has_password: undefined;
75
76
  otp_auth_enabled: undefined;
77
+ passkey_auth_enabled: undefined;
76
78
  client_metadata: undefined;
77
79
  client_read_only_metadata: undefined;
78
80
  server_metadata: undefined;
@@ -122,6 +124,7 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
122
124
  server_metadata: {} | null;
123
125
  primary_email_verified: NonNullable<boolean | undefined>;
124
126
  primary_email_auth_enabled: NonNullable<boolean | undefined>;
127
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
125
128
  otp_auth_enabled: NonNullable<boolean | undefined>;
126
129
  selected_team_id: string | null;
127
130
  selected_team: {
@@ -164,6 +167,7 @@ export declare const teamMemberProfilesCrud: import("../../crud").CrudSchemaFrom
164
167
  signed_up_at_millis: undefined;
165
168
  has_password: undefined;
166
169
  otp_auth_enabled: undefined;
170
+ passkey_auth_enabled: undefined;
167
171
  client_metadata: undefined;
168
172
  client_read_only_metadata: undefined;
169
173
  server_metadata: undefined;
@@ -8,6 +8,7 @@ export declare const usersCrudServerUpdateSchema: import("yup").ObjectSchema<{
8
8
  primary_email: string | null | undefined;
9
9
  primary_email_verified: boolean | undefined;
10
10
  primary_email_auth_enabled: boolean | undefined;
11
+ passkey_auth_enabled: boolean | undefined;
11
12
  password: string | null | undefined;
12
13
  otp_auth_enabled: boolean | undefined;
13
14
  totp_secret_base64: string | null | undefined;
@@ -21,6 +22,7 @@ export declare const usersCrudServerUpdateSchema: import("yup").ObjectSchema<{
21
22
  primary_email: undefined;
22
23
  primary_email_verified: undefined;
23
24
  primary_email_auth_enabled: undefined;
25
+ passkey_auth_enabled: undefined;
24
26
  password: undefined;
25
27
  otp_auth_enabled: undefined;
26
28
  totp_secret_base64: undefined;
@@ -46,6 +48,7 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
46
48
  signed_up_at_millis: number;
47
49
  has_password: NonNullable<boolean | undefined>;
48
50
  otp_auth_enabled: NonNullable<boolean | undefined>;
51
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
49
52
  client_metadata: {} | null;
50
53
  client_read_only_metadata: {} | null;
51
54
  server_metadata: {} | null;
@@ -77,6 +80,7 @@ export declare const usersCrudServerReadSchema: import("yup").ObjectSchema<{
77
80
  signed_up_at_millis: undefined;
78
81
  has_password: undefined;
79
82
  otp_auth_enabled: undefined;
83
+ passkey_auth_enabled: undefined;
80
84
  client_metadata: undefined;
81
85
  client_read_only_metadata: undefined;
82
86
  server_metadata: undefined;
@@ -95,6 +99,7 @@ export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
95
99
  server_metadata: {} | null | undefined;
96
100
  primary_email_verified: boolean | undefined;
97
101
  primary_email_auth_enabled: boolean | undefined;
102
+ passkey_auth_enabled: boolean | undefined;
98
103
  otp_auth_enabled: boolean | undefined;
99
104
  totp_secret_base64: string | null | undefined;
100
105
  } & {
@@ -112,6 +117,7 @@ export declare const usersCrudServerCreateSchema: import("yup").ObjectSchema<{
112
117
  primary_email: undefined;
113
118
  primary_email_verified: undefined;
114
119
  primary_email_auth_enabled: undefined;
120
+ passkey_auth_enabled: undefined;
115
121
  password: undefined;
116
122
  otp_auth_enabled: undefined;
117
123
  totp_secret_base64: undefined;
@@ -140,6 +146,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
140
146
  signed_up_at_millis: number;
141
147
  has_password: NonNullable<boolean | undefined>;
142
148
  otp_auth_enabled: NonNullable<boolean | undefined>;
149
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
143
150
  client_metadata: {} | null;
144
151
  client_read_only_metadata: {} | null;
145
152
  server_metadata: {} | null;
@@ -171,6 +178,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
171
178
  signed_up_at_millis: undefined;
172
179
  has_password: undefined;
173
180
  otp_auth_enabled: undefined;
181
+ passkey_auth_enabled: undefined;
174
182
  client_metadata: undefined;
175
183
  client_read_only_metadata: undefined;
176
184
  server_metadata: undefined;
@@ -188,6 +196,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
188
196
  primary_email: string | null | undefined;
189
197
  primary_email_verified: boolean | undefined;
190
198
  primary_email_auth_enabled: boolean | undefined;
199
+ passkey_auth_enabled: boolean | undefined;
191
200
  password: string | null | undefined;
192
201
  otp_auth_enabled: boolean | undefined;
193
202
  totp_secret_base64: string | null | undefined;
@@ -201,6 +210,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
201
210
  primary_email: undefined;
202
211
  primary_email_verified: undefined;
203
212
  primary_email_auth_enabled: undefined;
213
+ passkey_auth_enabled: undefined;
204
214
  password: undefined;
205
215
  otp_auth_enabled: undefined;
206
216
  totp_secret_base64: undefined;
@@ -216,6 +226,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
216
226
  server_metadata: {} | null | undefined;
217
227
  primary_email_verified: boolean | undefined;
218
228
  primary_email_auth_enabled: boolean | undefined;
229
+ passkey_auth_enabled: boolean | undefined;
219
230
  otp_auth_enabled: boolean | undefined;
220
231
  totp_secret_base64: string | null | undefined;
221
232
  } & {
@@ -233,6 +244,7 @@ export declare const usersCrud: import("../../crud").CrudSchemaFromOptions<{
233
244
  primary_email: undefined;
234
245
  primary_email_verified: undefined;
235
246
  primary_email_auth_enabled: undefined;
247
+ passkey_auth_enabled: undefined;
236
248
  password: undefined;
237
249
  otp_auth_enabled: undefined;
238
250
  totp_secret_base64: undefined;
@@ -291,6 +303,7 @@ export declare const userCreatedWebhookEvent: {
291
303
  signed_up_at_millis: number;
292
304
  has_password: NonNullable<boolean | undefined>;
293
305
  otp_auth_enabled: NonNullable<boolean | undefined>;
306
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
294
307
  client_metadata: {} | null;
295
308
  client_read_only_metadata: {} | null;
296
309
  server_metadata: {} | null;
@@ -322,6 +335,7 @@ export declare const userCreatedWebhookEvent: {
322
335
  signed_up_at_millis: undefined;
323
336
  has_password: undefined;
324
337
  otp_auth_enabled: undefined;
338
+ passkey_auth_enabled: undefined;
325
339
  client_metadata: undefined;
326
340
  client_read_only_metadata: undefined;
327
341
  server_metadata: undefined;
@@ -358,6 +372,7 @@ export declare const userUpdatedWebhookEvent: {
358
372
  signed_up_at_millis: number;
359
373
  has_password: NonNullable<boolean | undefined>;
360
374
  otp_auth_enabled: NonNullable<boolean | undefined>;
375
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
361
376
  client_metadata: {} | null;
362
377
  client_read_only_metadata: {} | null;
363
378
  server_metadata: {} | null;
@@ -389,6 +404,7 @@ export declare const userUpdatedWebhookEvent: {
389
404
  signed_up_at_millis: undefined;
390
405
  has_password: undefined;
391
406
  otp_auth_enabled: undefined;
407
+ passkey_auth_enabled: undefined;
392
408
  client_metadata: undefined;
393
409
  client_read_only_metadata: undefined;
394
410
  server_metadata: undefined;
@@ -10,6 +10,7 @@ export const usersCrudServerUpdateSchema = fieldSchema.yupObject({
10
10
  primary_email: fieldSchema.primaryEmailSchema.nullable().optional(),
11
11
  primary_email_verified: fieldSchema.primaryEmailVerifiedSchema.optional(),
12
12
  primary_email_auth_enabled: fieldSchema.primaryEmailAuthEnabledSchema.optional(),
13
+ passkey_auth_enabled: fieldSchema.userOtpAuthEnabledSchema.optional(),
13
14
  password: fieldSchema.userPasswordMutationSchema.optional(),
14
15
  otp_auth_enabled: fieldSchema.userOtpAuthEnabledMutationSchema.optional(),
15
16
  totp_secret_base64: fieldSchema.userTotpSecretMutationSchema.optional(),
@@ -27,6 +28,7 @@ export const usersCrudServerReadSchema = fieldSchema.yupObject({
27
28
  signed_up_at_millis: fieldSchema.signedUpAtMillisSchema.required(),
28
29
  has_password: fieldSchema.userHasPasswordSchema.required(),
29
30
  otp_auth_enabled: fieldSchema.userOtpAuthEnabledSchema.required(),
31
+ passkey_auth_enabled: fieldSchema.userOtpAuthEnabledSchema.required(),
30
32
  client_metadata: fieldSchema.userClientMetadataSchema,
31
33
  client_read_only_metadata: fieldSchema.userClientReadOnlyMetadataSchema,
32
34
  server_metadata: fieldSchema.userServerMetadataSchema,
@@ -35,7 +37,7 @@ export const usersCrudServerReadSchema = fieldSchema.yupObject({
35
37
  id: fieldSchema.yupString().required(),
36
38
  account_id: fieldSchema.yupString().required(),
37
39
  email: fieldSchema.yupString().nullable(),
38
- }).required()).required().meta({ openapiField: { hidden: true, description: 'A list of OAuth providers connected to this account', exampleValue: [{ id: 'google', account_id: '12345', email: 'john.doe@gmail.com' }] } }),
40
+ }).required()).required().meta({ openapiField: { hidden: true } }),
39
41
  /**
40
42
  * @deprecated
41
43
  */
@@ -50,7 +52,7 @@ export const usersCrudServerCreateSchema = usersCrudServerUpdateSchema.omit(['se
50
52
  id: fieldSchema.yupString().required(),
51
53
  account_id: fieldSchema.yupString().required(),
52
54
  email: fieldSchema.yupString().nullable().defined().default(null),
53
- }).required()).optional(),
55
+ }).required()).optional().meta({ openapiField: { hidden: true } }),
54
56
  }).required());
55
57
  export const usersCrudServerDeleteSchema = fieldSchema.yupMixed();
56
58
  export const usersCrud = createCrud({
@@ -45,7 +45,13 @@ export declare class StackServerInterface extends StackClientInterface {
45
45
  teamId?: string;
46
46
  recursive: boolean;
47
47
  }, session: InternalSession | null): Promise<TeamPermissionsCrud['Server']['Read'][]>;
48
- listServerUsers(): Promise<UsersCrud['Server']['Read'][]>;
48
+ listServerUsers(options: {
49
+ cursor?: string;
50
+ limit?: number;
51
+ orderBy?: 'signedUpAt';
52
+ desc?: boolean;
53
+ query?: string;
54
+ }): Promise<UsersCrud['Server']['List']>;
49
55
  listServerTeams(options?: {
50
56
  userId?: string;
51
57
  }): Promise<TeamsCrud['Server']['Read'][]>;
@@ -78,5 +84,5 @@ export declare class StackServerInterface extends StackClientInterface {
78
84
  updateServerContactChannel(userId: string, contactChannelId: string, data: ContactChannelsCrud['Server']['Update']): Promise<ContactChannelsCrud['Server']['Read']>;
79
85
  deleteServerContactChannel(userId: string, contactChannelId: string): Promise<void>;
80
86
  listServerContactChannels(userId: string): Promise<ContactChannelsCrud['Server']['Read'][]>;
81
- sendServerContactChannelVerificationEmail(userId: string, contactChannelId: string, callbackUrl: string): Promise<Result<undefined, KnownErrors["EmailAlreadyVerified"]>>;
87
+ sendServerContactChannelVerificationEmail(userId: string, contactChannelId: string, callbackUrl: string): Promise<void>;
82
88
  }
@@ -81,10 +81,22 @@ export class StackServerInterface extends StackClientInterface {
81
81
  const result = await response.json();
82
82
  return result.items;
83
83
  }
84
- async listServerUsers() {
85
- const response = await this.sendServerRequest("/users", {}, null);
86
- const result = await response.json();
87
- return result.items;
84
+ async listServerUsers(options) {
85
+ const searchParams = new URLSearchParams(filterUndefined({
86
+ cursor: options.cursor,
87
+ limit: options.limit?.toString(),
88
+ desc: options.desc?.toString(),
89
+ ...options.orderBy ? {
90
+ order_by: {
91
+ signedUpAt: "signed_up_at",
92
+ }[options.orderBy],
93
+ } : {},
94
+ ...options.query ? {
95
+ query: options.query,
96
+ } : {},
97
+ }));
98
+ const response = await this.sendServerRequest("/users?" + searchParams.toString(), {}, null);
99
+ return await response.json();
88
100
  }
89
101
  async listServerTeams(options) {
90
102
  const response = await this.sendServerRequest("/teams?" + new URLSearchParams(filterUndefined({
@@ -247,16 +259,12 @@ export class StackServerInterface extends StackClientInterface {
247
259
  return json.items;
248
260
  }
249
261
  async sendServerContactChannelVerificationEmail(userId, contactChannelId, callbackUrl) {
250
- const responseOrError = await this.sendServerRequestAndCatchKnownError(`/contact-channels/${userId}/${contactChannelId}/send-verification-code`, {
262
+ await this.sendServerRequest(`/contact-channels/${userId}/${contactChannelId}/send-verification-code`, {
251
263
  method: "POST",
252
264
  headers: {
253
265
  "content-type": "application/json",
254
266
  },
255
267
  body: JSON.stringify({ callback_url: callbackUrl }),
256
- }, null, [KnownErrors.EmailAlreadyVerified]);
257
- if (responseOrError.status === "error") {
258
- return Result.error(responseOrError.error);
259
- }
260
- return Result.ok(undefined);
268
+ }, null);
261
269
  }
262
270
  }
@@ -30,6 +30,7 @@ export declare const webhookEvents: readonly [{
30
30
  signed_up_at_millis: number;
31
31
  has_password: NonNullable<boolean | undefined>;
32
32
  otp_auth_enabled: NonNullable<boolean | undefined>;
33
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
33
34
  client_metadata: {} | null;
34
35
  client_read_only_metadata: {} | null;
35
36
  server_metadata: {} | null;
@@ -61,6 +62,7 @@ export declare const webhookEvents: readonly [{
61
62
  signed_up_at_millis: undefined;
62
63
  has_password: undefined;
63
64
  otp_auth_enabled: undefined;
65
+ passkey_auth_enabled: undefined;
64
66
  client_metadata: undefined;
65
67
  client_read_only_metadata: undefined;
66
68
  server_metadata: undefined;
@@ -96,6 +98,7 @@ export declare const webhookEvents: readonly [{
96
98
  signed_up_at_millis: number;
97
99
  has_password: NonNullable<boolean | undefined>;
98
100
  otp_auth_enabled: NonNullable<boolean | undefined>;
101
+ passkey_auth_enabled: NonNullable<boolean | undefined>;
99
102
  client_metadata: {} | null;
100
103
  client_read_only_metadata: {} | null;
101
104
  server_metadata: {} | null;
@@ -127,6 +130,7 @@ export declare const webhookEvents: readonly [{
127
130
  signed_up_at_millis: undefined;
128
131
  has_password: undefined;
129
132
  otp_auth_enabled: undefined;
133
+ passkey_auth_enabled: undefined;
130
134
  client_metadata: undefined;
131
135
  client_read_only_metadata: undefined;
132
136
  server_metadata: undefined;
@@ -251,6 +251,9 @@ export declare const KnownErrors: {
251
251
  PasswordAuthenticationNotEnabled: KnownErrorConstructor<KnownError & KnownErrorBrand<"PASSWORD_AUTHENTICATION_NOT_ENABLED">, []> & {
252
252
  errorCode: "PASSWORD_AUTHENTICATION_NOT_ENABLED";
253
253
  };
254
+ PasskeyAuthenticationNotEnabled: KnownErrorConstructor<KnownError & KnownErrorBrand<"PASSKEY_AUTHENTICATION_NOT_ENABLED">, []> & {
255
+ errorCode: "PASSKEY_AUTHENTICATION_NOT_ENABLED";
256
+ };
254
257
  EmailPasswordMismatch: KnownErrorConstructor<KnownError & KnownErrorBrand<"EMAIL_PASSWORD_MISMATCH">, []> & {
255
258
  errorCode: "EMAIL_PASSWORD_MISMATCH";
256
259
  };
@@ -308,6 +311,15 @@ export declare const KnownErrors: {
308
311
  EmailIsNotPrimaryEmail: KnownErrorConstructor<KnownError & KnownErrorBrand<"EMAIL_IS_NOT_PRIMARY_EMAIL">, [email: string, primaryEmail: string | null]> & {
309
312
  errorCode: "EMAIL_IS_NOT_PRIMARY_EMAIL";
310
313
  };
314
+ PasskeyRegistrationFailed: KnownErrorConstructor<KnownError & KnownErrorBrand<"PASSKEY_REGISTRATION_FAILED">, [message: string]> & {
315
+ errorCode: "PASSKEY_REGISTRATION_FAILED";
316
+ };
317
+ PasskeyWebAuthnError: KnownErrorConstructor<KnownError & KnownErrorBrand<"PASSKEY_WEBAUTHN_ERROR">, [message: string, code: string]> & {
318
+ errorCode: "PASSKEY_WEBAUTHN_ERROR";
319
+ };
320
+ PasskeyAuthenticationFailed: KnownErrorConstructor<KnownError & KnownErrorBrand<"PASSKEY_AUTHENTICATION_FAILED">, [message: string]> & {
321
+ errorCode: "PASSKEY_AUTHENTICATION_FAILED";
322
+ };
311
323
  PermissionNotFound: KnownErrorConstructor<KnownError & KnownErrorBrand<"PERMISSION_NOT_FOUND">, [permissionId: string]> & {
312
324
  errorCode: "PERMISSION_NOT_FOUND";
313
325
  };
@@ -328,6 +328,10 @@ const PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError,
328
328
  400,
329
329
  "Password authentication is not enabled for this project.",
330
330
  ], () => []);
331
+ const PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_NOT_ENABLED", () => [
332
+ 400,
333
+ "Passkey authentication is not enabled for this project.",
334
+ ], () => []);
331
335
  const EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [
332
336
  400,
333
337
  "Wrong e-mail or password.",
@@ -396,6 +400,22 @@ const EmailIsNotPrimaryEmail = createKnownErrorConstructor(KnownError, "EMAIL_IS
396
400
  primary_email: primaryEmail,
397
401
  },
398
402
  ], (json) => [json.email, json.primary_email]);
403
+ const PasskeyRegistrationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_REGISTRATION_FAILED", (message) => [
404
+ 400,
405
+ message,
406
+ ], (json) => [json.message]);
407
+ const PasskeyWebAuthnError = createKnownErrorConstructor(KnownError, "PASSKEY_WEBAUTHN_ERROR", (message, code) => [
408
+ 400,
409
+ message,
410
+ {
411
+ message,
412
+ code,
413
+ },
414
+ ], (json) => [json.message, json.code]);
415
+ const PasskeyAuthenticationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_FAILED", (message) => [
416
+ 400,
417
+ message,
418
+ ], (json) => [json.message]);
399
419
  const PermissionNotFound = createKnownErrorConstructor(KnownError, "PERMISSION_NOT_FOUND", (permissionId) => [
400
420
  404,
401
421
  `Permission "${permissionId}" not found. Make sure you created it on the dashboard.`,
@@ -586,6 +606,7 @@ export const KnownErrors = {
586
606
  ProjectNotFound,
587
607
  SignUpNotEnabled,
588
608
  PasswordAuthenticationNotEnabled,
609
+ PasskeyAuthenticationNotEnabled,
589
610
  EmailPasswordMismatch,
590
611
  RedirectUrlNotWhitelisted,
591
612
  PasswordRequirementsNotMet,
@@ -601,6 +622,9 @@ export const KnownErrors = {
601
622
  EmailAlreadyVerified,
602
623
  EmailNotAssociatedWithUser,
603
624
  EmailIsNotPrimaryEmail,
625
+ PasskeyRegistrationFailed,
626
+ PasskeyWebAuthnError,
627
+ PasskeyAuthenticationFailed,
604
628
  PermissionNotFound,
605
629
  ContainedPermissionNotFound,
606
630
  TeamNotFound,
@@ -39,6 +39,7 @@ export declare const projectConfigIdSchema: yup.StringSchema<string | undefined,
39
39
  export declare const projectAllowLocalhostSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
40
40
  export declare const projectCreateTeamOnSignUpSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
41
41
  export declare const projectMagicLinkEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
42
+ export declare const projectPasskeyEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
42
43
  export declare const projectClientTeamCreationEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
43
44
  export declare const projectClientUserDeletionEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
44
45
  export declare const projectSignUpEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
@@ -83,6 +84,7 @@ export declare const userOAuthProviderSchema: yup.ObjectSchema<{
83
84
  provider_user_id: undefined;
84
85
  }, "">;
85
86
  export declare const userLastActiveAtMillisSchema: yup.NumberSchema<number | null | undefined, yup.AnyObject, undefined, "">;
87
+ export declare const userPasskeyAuthEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
86
88
  export declare const userOtpAuthEnabledSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
87
89
  export declare const userOtpAuthEnabledMutationSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
88
90
  export declare const userHasPasswordSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
@@ -121,5 +123,11 @@ export declare const teamInvitationCallbackUrlSchema: yup.StringSchema<string |
121
123
  export declare const teamCreatorUserIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
122
124
  export declare const teamMemberDisplayNameSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
123
125
  export declare const teamMemberProfileImageUrlSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
126
+ export declare const contactChannelIdSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
127
+ export declare const contactChannelTypeSchema: yup.StringSchema<"email" | undefined, yup.AnyObject, undefined, "">;
128
+ export declare const contactChannelValueSchema: yup.StringSchema<string | undefined, yup.AnyObject, undefined, "">;
129
+ export declare const contactChannelUsedForAuthSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
130
+ export declare const contactChannelIsVerifiedSchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
131
+ export declare const contactChannelIsPrimarySchema: yup.BooleanSchema<boolean | undefined, yup.AnyObject, undefined, "">;
124
132
  export declare function yupRequiredWhen<S extends yup.AnyObject>(schema: S, triggerName: string, isValue: any): S;
125
133
  export {};
@@ -53,7 +53,7 @@ export async function yupValidate(schema, obj, options) {
53
53
  throw error;
54
54
  }
55
55
  }
56
- const _idDescription = (identify) => `The unique identifier of this ${identify}`;
56
+ const _idDescription = (identify) => `The unique identifier of the ${identify}`;
57
57
  const _displayNameDescription = (identify) => `Human-readable ${identify} display name. This is not a unique identifier.`;
58
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.`;
59
59
  const _clientReadOnlyMetaDataDescription = (identify) => `Client read-only, server-writable metadata. Used as a data store, accessible from the client side. Do not store information that should not be exposed to the client. The client can read this data, but cannot modify it. This is useful for things like subscription status.`;
@@ -203,6 +203,7 @@ export const projectConfigIdSchema = yupString().meta({ openapiField: { descript
203
203
  export const projectAllowLocalhostSchema = yupBoolean().meta({ openapiField: { description: 'Whether localhost is allowed as a domain for this project. Should only be allowed in development mode', exampleValue: true } });
204
204
  export const projectCreateTeamOnSignUpSchema = yupBoolean().meta({ openapiField: { description: 'Whether a team should be created for each user that signs up', exampleValue: true } });
205
205
  export const projectMagicLinkEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether magic link authentication is enabled for this project', exampleValue: true } });
206
+ export const projectPasskeyEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether passkey authentication is enabled for this project', exampleValue: true } });
206
207
  export const projectClientTeamCreationEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether client users can create teams', exampleValue: true } });
207
208
  export const projectClientUserDeletionEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether client users can delete their own account from the client', exampleValue: true } });
208
209
  export const projectSignUpEnabledSchema = yupBoolean().meta({ openapiField: { description: 'Whether users can sign up new accounts, or whether they are only allowed to sign in to existing accounts. Regardless of this option, the server API can always create new users with the `POST /users` endpoint.', exampleValue: true } });
@@ -263,6 +264,7 @@ export const userOAuthProviderSchema = yupObject({
263
264
  provider_user_id: yupString().required(),
264
265
  });
265
266
  export const userLastActiveAtMillisSchema = yupNumber().nullable().meta({ openapiField: { description: _lastActiveAtMillisDescription, exampleValue: 1630000000000 } });
267
+ export const userPasskeyAuthEnabledSchema = yupBoolean().meta({ openapiField: { hidden: true, description: 'Whether the user has passkeys enabled', exampleValue: false } });
266
268
  export const userOtpAuthEnabledSchema = yupBoolean().meta({ openapiField: { hidden: true, description: 'Whether the user has OTP/magic link enabled. ', exampleValue: true } });
267
269
  export const userOtpAuthEnabledMutationSchema = yupBoolean().meta({ openapiField: { hidden: true, description: 'Whether the user has OTP/magic link enabled. Note that only accounts with verified emails can sign-in with OTP.', exampleValue: true } });
268
270
  export const userHasPasswordSchema = yupBoolean().meta({ openapiField: { hidden: true, description: 'Whether the user has a password set. If the user does not have a password set, they will not be able to sign in with email/password.', exampleValue: true } });
@@ -318,6 +320,16 @@ export const teamCreatorUserIdSchema = userIdOrMeSchema.meta({ openapiField: { d
318
320
  // Team member profiles
319
321
  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' } });
320
322
  export const teamMemberProfileImageUrlSchema = urlSchema.max(1000000).meta({ openapiField: { description: _profileImageUrlDescription('team member'), exampleValue: 'https://example.com/image.jpg' } });
323
+ // Contact channels
324
+ export const contactChannelIdSchema = yupString().uuid().meta({ openapiField: { description: _idDescription('contact channel'), exampleValue: 'b3d396b8-c574-4c80-97b3-50031675ceb2' } });
325
+ export const contactChannelTypeSchema = yupString().oneOf(['email']).meta({ openapiField: { description: `The type of the contact channel. Currently only "email" is supported.`, exampleValue: 'email' } });
326
+ export const contactChannelValueSchema = yupString().when('type', {
327
+ is: 'email',
328
+ then: (schema) => schema.email(),
329
+ }).meta({ openapiField: { description: 'The value of the contact channel. For email, this should be a valid email address.', exampleValue: 'johndoe@example.com' } });
330
+ export const contactChannelUsedForAuthSchema = yupBoolean().meta({ openapiField: { description: 'Whether the contact channel is used for authentication. If this is set to `true`, the user will be able to sign in with the contact channel with password or OTP.', exampleValue: true } });
331
+ export const contactChannelIsVerifiedSchema = yupBoolean().meta({ openapiField: { description: 'Whether the contact channel has been verified. If this is set to `true`, the contact channel has been verified to belong to the user.', exampleValue: true } });
332
+ export const contactChannelIsPrimarySchema = yupBoolean().meta({ openapiField: { description: 'Whether the contact channel is the primary contact channel. If this is set to `true`, it will be used for authentication and notifications by default.', exampleValue: true } });
321
333
  // Utils
322
334
  export function yupRequiredWhen(schema, triggerName, isValue) {
323
335
  return schema.when(triggerName, {
@@ -0,0 +1 @@
1
+ export type { AuthenticationResponseJSON, RegistrationResponseJSON, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON, AuthenticatorAttestationResponseJSON } from "@simplewebauthn/types";
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackframe/stack-shared",
3
- "version": "2.6.12",
3
+ "version": "2.6.16",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -32,15 +32,17 @@
32
32
  }
33
33
  },
34
34
  "dependencies": {
35
+ "@simplewebauthn/browser": "^11.0.0",
35
36
  "bcrypt": "^5.1.1",
36
37
  "elliptic": "^6.5.7",
37
38
  "jose": "^5.2.2",
38
39
  "oauth4webapi": "^2.10.3",
39
40
  "semver": "^7.6.3",
40
41
  "uuid": "^9.0.1",
41
- "@stackframe/stack-sc": "2.6.12"
42
+ "@stackframe/stack-sc": "2.6.16"
42
43
  },
43
44
  "devDependencies": {
45
+ "@simplewebauthn/types": "^11.0.0",
44
46
  "@types/bcrypt": "^5.0.2",
45
47
  "@types/elliptic": "^6.4.18",
46
48
  "@types/react": "^18.2.66",