@stackframe/stack-shared 2.6.12 → 2.6.15

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,25 @@
1
1
  # @stackframe/stack-shared
2
2
 
3
+ ## 2.6.15
4
+
5
+ ### Patch Changes
6
+
7
+ - Passkeys
8
+ - @stackframe/stack-sc@2.6.15
9
+
10
+ ## 2.6.14
11
+
12
+ ### Patch Changes
13
+
14
+ - @stackframe/stack-sc@2.6.14
15
+
16
+ ## 2.6.13
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated docs
21
+ - @stackframe/stack-sc@2.6.13
22
+
3
23
  ## 2.6.12
4
24
 
5
25
  ### Patch Changes
@@ -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"]) {
@@ -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({
@@ -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, "">;
@@ -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 } });
@@ -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.15",
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.15"
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",