@stytch/vanilla-js 4.5.3 → 4.5.5

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.
@@ -1,743 +1,4 @@
1
- import { IHeadlessB2BDiscoveryClient, IHeadlessB2BMagicLinksClient, IHeadlessB2BMemberClient, IHeadlessB2BSelfClient, IHeadlessB2BOAuthClient, IHeadlessB2BOrganizationClient, IHeadlessB2BOTPsClient, IHeadlessB2BTOTPsClient, IHeadlessB2BSessionClient, IHeadlessB2BSSOClient, IHeadlessB2BRecoveryCodesClient, IHeadlessB2BRBACClient, StytchClientOptions } from "@stytch/core/public";
2
- import { Callbacks as Callbacks$0 } from "@stytch/core/public";
3
- import { StyleConfig as StyleConfig$0 } from "@stytch/core/public";
4
- import { StytchB2BUIConfig as StytchB2BUIConfig$0 } from "@stytch/core/public";
5
- type ResponseCommon = {
6
- /**
7
- * Globally unique UUID that is returned with every API call.
8
- * This value is important to log for debugging purposes;
9
- * Stytch may ask for this value to help identify a specific API call when helping you debug an issue.
10
- */
11
- request_id: string;
12
- /**
13
- * The HTTP status code of the response.
14
- * Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success,
15
- * 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
16
- */
17
- status_code: number;
18
- };
19
- type SessionDurationOptions = {
20
- /**
21
- * Set the session lifetime to be this many minutes from now.
22
- * This will return both an opaque `session_token` and `session_jwt` for this session, which will automatically be stored in the browser cookies.
23
- * The `session_jwt` will have a fixed lifetime of five minutes regardless of the underlying session duration, and will be automatically refreshed by the SDK in the background over time.
24
- * This value must be a minimum of 5 and may not exceed the maximum session duration minutes value set in the
25
- * {@link https://stytch.com/dashboard/sdk-configuration SDK Configuration } page of the Stytch dashboard.
26
- */
27
- session_duration_minutes: number;
28
- };
29
- type locale = "en" | "es" | "pt-br" | string;
30
- // Authentication Factors
31
- interface B2BEmailFactor {
32
- delivery_method: "email";
33
- type: string;
34
- last_authenticated_at: string;
35
- email_factor: {
36
- email_id: string;
37
- email_address: string;
38
- };
39
- sequence_order: "PRIMARY";
40
- }
41
- interface B2BPhoneNumberFactor {
42
- delivery_method: "sms" | "whatsapp";
43
- type: string;
44
- last_authenticated_at: string;
45
- phone_number_factor: {
46
- phone_id: string;
47
- phone_number: string;
48
- };
49
- sequence_order: "SECONDARY";
50
- }
51
- interface B2BGoogleOAuthFactor {
52
- delivery_method: "oauth_google";
53
- type: string;
54
- last_authenticated_at: string;
55
- google_oauth_factor: {
56
- id: string;
57
- email_id: string;
58
- provider_subject: string;
59
- };
60
- sequence_order: "PRIMARY";
61
- }
62
- interface B2BMicrosoftOAuthFactor {
63
- delivery_method: "oauth_microsoft";
64
- type: string;
65
- last_authenticated_at: string;
66
- microsoft_oauth_factor: {
67
- id: string;
68
- email_id: string;
69
- provider_subject: string;
70
- };
71
- sequence_order: "PRIMARY";
72
- }
73
- type B2BAuthenticationFactor = B2BEmailFactor | B2BPhoneNumberFactor | B2BGoogleOAuthFactor | B2BMicrosoftOAuthFactor;
74
- type MemberResponseCommon = ResponseCommon & {
75
- /**
76
- * Globally unique UUID that identifies a specific member in the Stytch API.
77
- * The member_id critical to perform operations on a member in our API
78
- * so be sure to preserve this value.
79
- */
80
- member_id: string;
81
- /**
82
- * The Member object.
83
- * See {@link Member} for details.
84
- */
85
- member: Member;
86
- /**
87
- * The Organization object.
88
- * See {@link Organization} for details.
89
- */
90
- organization: Organization;
91
- };
92
- interface MemberSession {
93
- /**
94
- * Globally unique UUID that identifies a specific member session in the Stytch API.
95
- */
96
- member_session_id: string;
97
- /**
98
- * Globally unique UUID that identifies a specific member in the Stytch API.
99
- * The member_id critical to perform operations on a member in our API
100
- * so be sure to preserve this value.
101
- */
102
- member_id: string;
103
- /**
104
- * Globally unique UUID that identifies an organization in the Stytch API.
105
- */
106
- organization_id: string;
107
- /**
108
- * The timestamp of the session's creation.
109
- * Values conform to the RFC 3339 standard and are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
110
- */
111
- started_at: string;
112
- /**
113
- * The timestamp of the last time the session was accessed.
114
- * Values conform to the RFC 3339 standard and are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
115
- */
116
- last_accessed_at: string;
117
- /**
118
- * The timestamp of the session's expiration.
119
- * Values conform to the RFC 3339 standard and are expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
120
- */
121
- expires_at: string;
122
- /**
123
- * All the authentication factors that have been associated with the current member session.
124
- */
125
- authentication_factors: B2BAuthenticationFactor[];
126
- /**
127
- * A map of the custom claims associated with the session.
128
- * Custom claims can only be set from the server, they cannot be set using the clientside SDKs.
129
- * After claims have been added to a session, call {@link IHeadlessB2BSessionClient#authenticate stytch.sessions.authenticate} to refresh the session state clientside.
130
- * See our {@link https://stytch.com/docs/sessions#using-sessions_custom-claims guide} for more information.
131
- * If no claims are set, this field will be null.
132
- */
133
- custom_claims?: Record<string, unknown>;
134
- /**
135
- * A list of the roles associated with the session.
136
- * Members may inherit certain roles depending on the factors in their session.
137
- * For example, some roles may only be active if the member logged in from a specific SAML IDP.
138
- */
139
- roles: string[];
140
- }
141
- interface SSORegistration {
142
- connection_id: string;
143
- external_id: string;
144
- registration_id: string;
145
- sso_attributes: Record<string, unknown>;
146
- }
147
- type RoleSource = {
148
- type: "direct_assignment";
149
- details: Record<string, never>;
150
- } | {
151
- type: "email_assignment";
152
- details: {
153
- email_domain: string;
154
- };
155
- } | {
156
- type: "sso_connection";
157
- details: {
158
- connection_id: string;
159
- };
160
- } | {
161
- type: "sso_connection_group";
162
- details: {
163
- connection_id: string;
164
- group: string;
165
- };
166
- };
167
- interface Member {
168
- /**
169
- * Globally unique UUID that identifies an organization in the Stytch API.
170
- */
171
- organization_id: string;
172
- /**
173
- * Globally unique UUID that identifies a specific member in the Stytch API.
174
- * The member_id critical to perform operations on a member in our API
175
- * so be sure to preserve this value.
176
- */
177
- member_id: string;
178
- /**
179
- * The email address of the member.
180
- */
181
- email_address: string;
182
- /**
183
- * Whether the member's email address is verified.
184
- */
185
- email_address_verified: boolean;
186
- /**
187
- * The `status` value denotes whether or not a user has successfully logged in at least once with any available login method.
188
- */
189
- status: string;
190
- /**
191
- * The name of the member
192
- */
193
- name: string;
194
- /**
195
- * A JSON object containing application-specific metadata.
196
- * This field can only be updated by a direct API integration.
197
- * Use it to store fields that a member should not be allowed to edit without backend validation - such as `role` or `subscription_status`.
198
- * See our {@link https://stytch.com/docs/api/metadata metadata reference} for complete details.
199
- */
200
- trusted_metadata: Record<string, unknown>;
201
- /**
202
- * A JSON object containing application-specific metadata.
203
- * Use it to store fields that a member can be allowed to edit directly without backend validation - such as `display_theme` or `preferred_locale`.
204
- * See our {@link https://stytch.com/docs/api/metadata metadata reference} for complete details.
205
- */
206
- untrusted_metadata: Record<string, unknown>;
207
- sso_registrations: SSORegistration[];
208
- /**
209
- * Identifies the Member as a break glass user - someone who has permissions to authenticate into an Organization by bypassing the Organization's settings.
210
- * A break glass account is typically used for emergency purposes to gain access outside of normal authentication procedures.
211
- */
212
- is_breakglass: boolean;
213
- /**
214
- * Returned if the member has a registered password
215
- */
216
- member_password_id: string;
217
- /**
218
- * If true, the member must complete a secondary authentication flow, such as SMS OTP, along with their
219
- * primary authentication factor in order to log in and attain a member session.
220
- */
221
- mfa_enrolled: boolean;
222
- /**
223
- * Returned if the member has a phone number.
224
- */
225
- mfa_phone_number: string;
226
- /**
227
- * Whether the member's phone number is verified.
228
- */
229
- mfa_phone_number_verified: boolean;
230
- /**
231
- * A list of the member's roles and their sources
232
- */
233
- roles: {
234
- role_id: string;
235
- sources: RoleSource[];
236
- }[];
237
- /**
238
- * The member's default MFA method.
239
- */
240
- default_mfa_method: string;
241
- }
242
- type B2BAuthenticateResponse = ResponseCommon & {
243
- /**
244
- * Globally unique UUID that identifies a specific member in the Stytch API.
245
- * The member_id critical to perform operations on a member in our API
246
- * so be sure to preserve this value.
247
- */
248
- member_id: string;
249
- /**
250
- * An opaque session token.
251
- * Session tokens need to be authenticated via the {@link https://stytch.com/docs/b2b/api/authenticate-session SessionsAuthenticate}
252
- * endpoint before a member takes any action that requires authentication
253
- * See {@link https://stytch.com/docs/sessions#session-tokens-vs-JWTs_tokens our documentation} for more information.
254
- */
255
- session_token: string;
256
- /**
257
- * A JSON Web Token that contains standard claims about the user as well as information about the Stytch session
258
- * Session JWTs can be authenticated locally without an API call.
259
- * A session JWT is signed by project-specific keys stored by Stytch.
260
- * See {@link https://stytch.com/docs/sessions#session-tokens-vs-JWTs_jwts our documentation} for more information.
261
- */
262
- session_jwt: string;
263
- /**
264
- * The Member Session object.
265
- * See {@link MemberSession} for details.
266
- */
267
- member_session: MemberSession;
268
- /**
269
- * The Member object.
270
- * See {@link Member} for details.
271
- */
272
- member: Member;
273
- /**
274
- * The Organization object.
275
- * See {@link Organization} for details.
276
- */
277
- organization: Organization;
278
- };
279
- type B2BAuthenticateResponseWithMFA = Omit<B2BAuthenticateResponse, "member_session"> & ({
280
- /**
281
- * The Member Session object.
282
- * See {@link MemberSession} for details.
283
- */
284
- member_session: MemberSession;
285
- /**
286
- * Returns true if the member is fully authenticated, in which case a member session is returned.
287
- * Returns false if the member still needs to complete a secondary authentication requirement,
288
- * in which case an intermediate_session_token is returned.
289
- */
290
- member_authenticated: true;
291
- /**
292
- * If the intermediate_session_token is present, the member needs to complete MFA.
293
- * The intermediate_session_token can be passed into a secondary authentication endpoint, such as OTP authenticate,
294
- * in order to receive a member session. The intermediate_session_token can also be used with discovery endpoints
295
- * to join a different organization or create a new organization.
296
- */
297
- intermediate_session_token: "";
298
- /**
299
- * Contains information about the member's options for completing MFA, if applicable.
300
- */
301
- mfa_required: null;
302
- } | {
303
- /**
304
- * The Member Session object.
305
- * See {@link MemberSession} for details.
306
- */
307
- member_session: null;
308
- /**
309
- * Returns true if the member is fully authenticated, in which case a member session is returned.
310
- * Returns false if the member still needs to complete a secondary authentication requirement,
311
- * in which case an intermediate_session_token is returned.
312
- */
313
- member_authenticated: false;
314
- /**
315
- * If the intermediate_session_token is present, the member needs to complete MFA.
316
- * The intermediate_session_token can be passed into a secondary authentication endpoint, such as OTP authenticate,
317
- * in order to receive a member session. The intermediate_session_token can also be used with discovery endpoints
318
- * to join a different organization or create a new organization.
319
- */
320
- intermediate_session_token: string;
321
- /**
322
- * Contains information about the member's options for completing MFA, if applicable.
323
- */
324
- mfa_required: MfaRequired;
325
- });
326
- interface Organization {
327
- /**
328
- * Globally unique UUID that identifies an organization in the Stytch API.
329
- */
330
- organization_id: string;
331
- /**
332
- * The name of the organization.
333
- */
334
- organization_name: string;
335
- /**
336
- * The slug of the organization.
337
- */
338
- organization_slug: string;
339
- /**
340
- * A URL of the organization's logo.
341
- */
342
- organization_logo_url: string;
343
- /**
344
- * A JSON object containing application-specific metadata.
345
- * This field can only be updated by a direct API integration.
346
- */
347
- trusted_metadata: Record<string, unknown>;
348
- /**
349
- * The default connection used for SSO when there are multiple active connections.
350
- */
351
- sso_default_connection_id: string | null;
352
- /**
353
- * The authentication setting that controls the JIT provisioning of Members when authenticating via SSO.
354
- * The accepted values are:
355
- * ALL_ALLOWED – new Members will be automatically provisioned upon successful authentication via any of the Organization's sso_active_connections.
356
- * RESTRICTED – only new Members with SSO logins that comply with sso_jit_provisioning_allowed_connections can be provisioned upon authentication.
357
- * NOT_ALLOWED – disable JIT provisioning via SSO.
358
- */
359
- sso_jit_provisioning: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
360
- /**
361
- * An array of connection_ids that reference SAML Connection objects.
362
- * Only these connections will be allowed to JIT provision Members via SSO when sso_jit_provisioning is set to RESTRICTED.
363
- */
364
- sso_jit_provisioning_allowed_connections: string[];
365
- /**
366
- * An array of active SSO Connection references.
367
- */
368
- sso_active_connections: {
369
- connection_id: string;
370
- display_name: string;
371
- }[];
372
- /**
373
- * An array of email domains that allow invites or JIT provisioning for new Members.
374
- * This list is enforced when either email_invites or email_jit_provisioning is set to RESTRICTED.
375
- * Common domains such as gmail.com are not allowed.
376
- */
377
- email_allowed_domains: string[];
378
- /**
379
- * The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link.
380
- * The accepted values are:
381
- * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be provisioned upon authentication via Email Magic Link.
382
- * NOT_ALLOWED – disable JIT provisioning via Email Magic Link.
383
- */
384
- email_jit_provisioning: "RESTRICTED" | "NOT_ALLOWED";
385
- /**
386
- * The authentication setting that controls how a new Member can be invited to an organization by email.
387
- * The accepted values are:
388
- * ALL_ALLOWED – any new Member can be invited to join via email.
389
- * RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be invited via email.
390
- * NOT_ALLOWED – disable email invites.
391
- */
392
- email_invites: "ALL_ALLOWED" | "RESTRICTED" | "NOT_ALLOWED";
393
- /**
394
- * The setting that controls which authentication methods can be used by Members of an Organization.
395
- * The accepted values are:
396
- * ALL_ALLOWED – the default setting which allows all authentication methods to be used.
397
- * RESTRICTED – only methods that comply with allowed_auth_methods can be used for authentication. This setting does not apply to Members with is_breakglass set to true.
398
- */
399
- auth_methods: "ALL_ALLOWED" | "RESTRICTED";
400
- /**
401
- * An array of allowed authentication methods.
402
- * This list is enforced when auth_methods is set to RESTRICTED.
403
- * The list's accepted values are: sso, magic_link, password, google_oauth, and microsoft_oauth.
404
- */
405
- allowed_auth_methods: string[];
406
- /**
407
- * The setting that controls which mfa methods can be used by Members of an Organization.
408
- * The accepted values are:
409
- * ALL_ALLOWED – the default setting which allows all MFA methods to be used.
410
- * RESTRICTED – only methods that comply with allowed_mfa_methods can be used for MFA. This setting does not apply to Members with is_breakglass set to true.
411
- */
412
- mfa_methods?: string;
413
- /**
414
- * An array of allowed MFA methods.
415
- * This list is enforced when mfa_methods is set to RESTRICTED.
416
- * The list's accepted values are: sms_otp and totp.
417
- */
418
- allowed_mfa_methods?: ("sms_otp" | "totp")[];
419
- /**
420
- * The setting that controls the MFA policy for all Members in the Organization. The accepted values are:
421
- * REQUIRED_FOR_ALL – All Members within the Organization will be required to complete MFA every time they wish to log in.
422
- * OPTIONAL – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their mfa_enrolled status is set to true
423
- */
424
- mfa_policy: "OPTIONAL" | "REQUIRED_FOR_ALL";
425
- /**
426
- * An array of implicit role assignments granted to members in this organization whose emails match the domain.
427
- */
428
- rbac_email_implicit_role_assignments?: {
429
- role_id: string;
430
- domain: string;
431
- }[];
432
- }
433
- interface MfaRequired {
434
- member_options: MemberOptions | null;
435
- /**
436
- * Equal to 'sms_otp' if an OTP code was sent to the member's phone number.
437
- */
438
- secondary_auth_initiated: "sms_otp" | null;
439
- }
440
- interface MemberOptions {
441
- mfa_phone_number: string;
442
- }
443
- type B2BPasswordAuthenticateOptions = SessionDurationOptions & {
444
- /**
445
- * The id of the Organization under which the Member and password belong
446
- */
447
- organization_id: string;
448
- /**
449
- * The email of the Member.
450
- */
451
- email_address: string;
452
- /**
453
- * The password for the Member.
454
- */
455
- password: string;
456
- /**
457
- * The locale will be used if an OTP code is sent to the member's phone number as part of a
458
- * secondary authentication requirement.
459
- */
460
- locale?: locale;
461
- };
462
- type B2BPasswordAuthenticateResponse = B2BAuthenticateResponseWithMFA;
463
- type B2BPasswordResetByEmailStartOptions = {
464
- /**
465
- * The id of the Organization under which the Member and password belong
466
- */
467
- organization_id: string;
468
- /**
469
- * The email of the Member that requested the password reset.
470
- */
471
- email_address: string;
472
- /**
473
- * The url that the Member clicks from the password reset email to skip resetting their password and directly login.
474
- * This should be a url that your app receives, parses, and subsequently sends an API request to the magic link authenticate endpoint to complete the login process without reseting their password.
475
- * If this value is not passed, the login redirect URL that you set in your Dashboard is used.
476
- * If you have not set a default login redirect URL, an error is returned.
477
- */
478
- login_redirect_url?: string;
479
- /**
480
- * The url that the Member clicks from the password reset email to finish the reset password flow.
481
- * This should be a url that your app receives and parses before showing your app's reset password page.
482
- * After the Member submits a new password to your app, it should send an API request to complete the password reset process.
483
- * If this value is not passed, the default reset password redirect URL that you set in your Dashboard is used.
484
- * If you have not set a default reset password redirect URL, an error is returned.
485
- */
486
- reset_password_redirect_url?: string;
487
- /**
488
- * Set the expiration for the password reset, in minutes.
489
- * By default, it expires in 30 minutes.
490
- * The minimum expiration is 5 minutes and the maximum is 7 days (10080 mins).
491
- */
492
- reset_password_expiration_minutes?: number;
493
- /**
494
- * The email template ID to use for password reset.
495
- * If not provided, your default email template will be sent. If providing a template ID, it must be either a template using Stytch's customizations,
496
- * or a Passwords reset custom HTML template.
497
- */
498
- reset_password_template_id?: string;
499
- };
500
- type B2BPasswordResetByEmailStartResponse = MemberResponseCommon;
501
- type B2BPasswordResetByEmailOptions = SessionDurationOptions & {
502
- /**
503
- * The token to authenticate.
504
- */
505
- password_reset_token: string;
506
- /**
507
- * The new password for the Member.
508
- */
509
- password: string;
510
- /**
511
- * The locale will be used if an OTP code is sent to the member's phone number as part of a
512
- * secondary authentication requirement.
513
- */
514
- locale?: locale;
515
- };
516
- type B2BPasswordResetByEmailResponse = B2BAuthenticateResponseWithMFA;
517
- type B2BPasswordResetByExistingPasswordOptions = SessionDurationOptions & {
518
- /**
519
- * The id of the Organization under which the Member and password belong
520
- */
521
- organization_id: string;
522
- /**
523
- * The Member's email.
524
- */
525
- email_address: string;
526
- /**
527
- * The Member's existing password.
528
- */
529
- existing_password: string;
530
- /**
531
- * The new password for the Member.
532
- */
533
- new_password: string;
534
- /**
535
- * The locale will be used if an OTP code is sent to the member's phone number as part of a
536
- * secondary authentication requirement.
537
- */
538
- locale?: locale;
539
- };
540
- type B2BPasswordResetByExistingPasswordResponse = B2BAuthenticateResponseWithMFA;
541
- type B2BPasswordResetBySessionOptions = {
542
- /**
543
- * The new password for the Member.
544
- */
545
- password: string;
546
- };
547
- type B2BPasswordResetBySessionResponse = B2BAuthenticateResponse;
548
- type B2BPasswordStrengthCheckOptions = {
549
- /**
550
- * The email associated with the password. Provide this for a more accurate strength check.
551
- */
552
- email_address?: string;
553
- /**
554
- * The password to strength check.
555
- */
556
- password: string;
557
- };
558
- type B2BPasswordStrengthCheckResponse = MemberResponseCommon & {
559
- /**
560
- * Whether the password is considered valid and secure.
561
- * Read more about password validity {@link https://stytch.com/docs/api/password-strength-check in our docs}.
562
- */
563
- valid_password: boolean;
564
- /**
565
- * The score of the password as determined by {@link https://github.com/dropbox/zxcvbn zxcvbn}.
566
- */
567
- score: number;
568
- /**
569
- * Determines if the password has been breached using {@link https://haveibeenpwned.com/ HaveIBeenPwned}.
570
- */
571
- breached_password: boolean;
572
- /**
573
- * Will return true if breach detection will be evaluated. By default this option is enabled.
574
- * This option can be disabled by contacting support@stytch.com. If this value is false then
575
- * breached_password will always be false as well.
576
- */
577
- breach_detection_on_create: boolean;
578
- /**
579
- * The strength policy type enforced, either `zxcvbn` or `luds`.
580
- */
581
- strength_policy: "luds" | "zxcvbn";
582
- /**
583
- * Feedback for how to improve the password's strength using {@link https://github.com/dropbox/zxcvbn zxcvbn}.
584
- */
585
- zxcvbn_feedback: {
586
- suggestions: string[];
587
- warning: string;
588
- };
589
- /**
590
- * Feedback for how to improve the password's strength using Lowercase Uppercase Digits Special Characters
591
- */
592
- luds_feedback: {
593
- has_lower_case: boolean;
594
- has_upper_case: boolean;
595
- has_digit: boolean;
596
- has_symbol: boolean;
597
- missing_complexity: number;
598
- missing_characters: number;
599
- };
600
- };
601
- interface IHeadlessB2BPasswordClient {
602
- /**
603
- * The Authenticate method wraps the {@link https://stytch.com/docs/b2b/api/passwords-authenticate Authenticate} Password API endpoint.
604
- * This endpoint verifies that the Member has a password currently set, and that the entered password is correct.
605
- *
606
- * There are cases where this endpoint will return a `reset_password` error even if the password entered is correct.
607
- * View our {@link https://stytch.com/docs/api/password-authenticate API Docs} for complete details.
608
- *
609
- * If this method succeeds, the Member will be logged in, granted an active session, and the
610
- * {@link https://stytch.com/docs/sdks/javascript-sdk/resources/cookies-and-session-management session cookies} will be minted and stored in the browser.
611
- *
612
- * @example
613
- * stytch.passwords.authenticate({
614
- * email_address: 'sandbox@stytch.com',
615
- * password: 'aVerySecurePassword',
616
- * session_duration_minutes: 60
617
- * });
618
- *
619
- * @param options - {@link B2BPasswordAuthenticateOptions}
620
- *
621
- * @returns A {@link B2BPasswordAuthenticateResponse} indicating the password is valid and that the Member is now logged in.
622
- *
623
- * @throws A `StytchAPIError` when the Stytch API returns an error.
624
- * @throws A `StytchAPIUnreachableError` when the SDK cannot contact the Stytch API.
625
- * @throws A `StytchSDKUsageError` when called with invalid input (invalid email, invalid options, etc.)
626
- */
627
- authenticate(options: B2BPasswordAuthenticateOptions): Promise<B2BPasswordAuthenticateResponse>;
628
- /**
629
- * The resetByEmailStart method wraps the {@link https://stytch.com/docs/b2b/api/email-reset-start Reset By Email Start} Password API endpoint.
630
- * This endpoint initiates a password reset for the email address provided.
631
- * This will trigger an email to be sent to the address, containing a magic link that will allow them to set a new password and authenticate.
632
- *
633
- * @example
634
- * stytch.passwords.resetByEmailStart({
635
- * email_address: 'sandbox@stytch.com',
636
- * reset_password_redirect_url: 'https://example.com/login/reset',
637
- * reset_password_expiration_minutes: 10,
638
- * login_redirect_url: 'https://example.com/login/authenticate',
639
- * });
640
- *
641
- * @param options - {@link B2BPasswordResetByEmailStartOptions}
642
- *
643
- * @returns A {@link B2BPasswordResetByEmailStartResponse} indicating the password is valid and that the Member is now logged in.
644
- *
645
- * @throws A `StytchAPIError` when the Stytch API returns an error.
646
- * @throws A `StytchAPIUnreachableError` when the SDK cannot contact the Stytch API.
647
- * @throws A `StytchSDKUsageError` when called with invalid input (invalid email, invalid options, etc.)
648
- */
649
- resetByEmailStart(options: B2BPasswordResetByEmailStartOptions): Promise<B2BPasswordResetByEmailStartResponse>;
650
- /**
651
- * The resetByEmail method wraps the {@link https://stytch.com/docs/b2b/api/email-reset Reset By Email} Password API endpoint.
652
- * This endpoint the Member’s password and authenticate them.
653
- * This endpoint checks that the magic link token is valid, hasn't expired, or already been used.
654
- * The provided password needs to meet our password strength requirements, which can be checked in advance with the {@link IHeadlessB2BPasswordClient#strengthCheck password strength} endpoint.
655
- *
656
- * If this method succeeds, the Member will be logged in, granted an active session, and the
657
- * {@link https://stytch.com/docs/sdks/javascript-sdk/resources/cookies-and-session-management session cookies} will be minted and stored in the browser.
658
- *
659
- * @example
660
- * const currentLocation = new URL(window.location.href);
661
- * const token = currentLocation.searchParams.get('token');
662
- * stytch.passwords.resetByEmail({
663
- * token,
664
- * email_address: 'sandbox@stytch.com',
665
- * password: 'aVerySecurePassword',
666
- * session_duration_minutes: 60
667
- * });
668
- *
669
- * @param options - {@link B2BPasswordResetByEmailOptions}
670
- *
671
- * @returns A {@link B2BPasswordResetByEmailResponse} indicating the password is valid and that the Member is now logged in.
672
- *
673
- * @throws A `StytchAPIError` when the Stytch API returns an error.
674
- * @throws A `StytchAPIUnreachableError` when the SDK cannot contact the Stytch API.
675
- * @throws A `StytchSDKUsageError` when called with invalid input (invalid email, invalid options, etc.)
676
- */
677
- resetByEmail(options: B2BPasswordResetByEmailOptions): Promise<B2BPasswordResetByEmailResponse>;
678
- /**
679
- * The strengthCheck method wraps the {@link https://stytch.com/docs/b2b/api/strength-check Strength Check} Password API endpoint.
680
- * This endpoint allows you to check whether or not the Member’s provided password is valid,
681
- * and to provide feedback to the Member on how to increase the strength of their password.
682
- *
683
- * @example
684
- * const {valid_password, feedback} = await stytch.passwords.strengthCheck({ email, password });
685
- * if (!valid_password) {
686
- * throw new Error('Password is not strong enough: ' + feedback.warning);
687
- * }
688
- *
689
- * @param options - {@link B2BPasswordStrengthCheckOptions}
690
- *
691
- * @returns A {@link B2BPasswordStrengthCheckResponse} containing password strength feedback.
692
- *
693
- * @throws A `StytchAPIError` when the Stytch API returns an error.
694
- * @throws A `StytchAPIUnreachableError` when the SDK cannot contact the Stytch API.
695
- * @throws A `StytchSDKUsageError` when called with invalid input (invalid email, invalid options, etc.)
696
- */
697
- strengthCheck(options: B2BPasswordStrengthCheckOptions): Promise<B2BPasswordStrengthCheckResponse>;
698
- /**
699
- * The resetByExistingPassword method wraps the {@link https://stytch.com/docs/b2b/api/existing-reset Reset By Existing Password} API endpoint.
700
- * If this method succeeds, the Member will be logged in, granted an active session, and the
701
- * {@link https://stytch.com/docs/sdks/javascript-sdk/resources/cookies-and-session-management session cookies} will be minted and stored in the browser.
702
- * You can listen for successful login events anywhere in the codebase with the `stytch.session.onChange()` method or `useStytchSession` hook if you are using React.
703
- *
704
- * @example
705
- * stytch.passwords.resetByExistingPassword({
706
- * email_address: 'sandbox@stytch.com',
707
- * existing_password: 'aVerySecurePassword',
708
- * new_password: 'aVerySecureNewPassword'
709
- * });
710
- *
711
- * @param options - {@link B2BPasswordResetByExistingPasswordOptions}
712
- *
713
- * @returns A {@link B2BPasswordResetByExistingPasswordResponse} indicating the password is valid and that the Member is now logged in.
714
- *
715
- * @throws A `StytchAPIError` when the Stytch API returns an error.
716
- * @throws A `StytchAPIUnreachableError` when the SDK cannot contact the Stytch API.
717
- * @throws A `StytchSDKUsageError` when called with invalid input (invalid email, invalid options, etc.)
718
- */
719
- resetByExistingPassword(options: B2BPasswordResetByExistingPasswordOptions): Promise<B2BPasswordResetByExistingPasswordResponse>;
720
- /**
721
- * The resetBySession method wraps the {@link https://stytch.com/docs/b2b/api/session-reset Reset By Session} API endpoint.
722
- * If this method succeeds, the Member will be logged in, granted an active session, and the
723
- * {@link https://stytch.com/docs/sdks/javascript-sdk/resources/cookies-and-session-management session cookies} will be minted and stored in the browser.
724
- * You can listen for successful login events anywhere in the codebase with the `stytch.session.onChange()` method or `useStytchSession` hook if you are using React.
725
- *
726
- * @example
727
- * stytch.passwords.resetBySession({
728
- * password: 'aVerySecurePassword'
729
- * });
730
- *
731
- * @param options - {@link B2BPasswordResetBySessionOptions}
732
- *
733
- * @returns A {@link B2BPasswordResetBySessionResponse} indicating the password is valid and that the Member is now logged in.
734
- *
735
- * @throws A `StytchAPIError` when the Stytch API returns an error.
736
- * @throws A `StytchAPIUnreachableError` when the SDK cannot contact the Stytch API.
737
- * @throws A `StytchSDKUsageError` when called with invalid input (invalid email, invalid options, etc.)
738
- */
739
- resetBySession(options: B2BPasswordResetBySessionOptions): Promise<B2BPasswordResetBySessionResponse>;
740
- }
1
+ import { IHeadlessB2BDiscoveryClient, IHeadlessB2BMagicLinksClient, IHeadlessB2BMemberClient, IHeadlessB2BSelfClient, IHeadlessB2BOAuthClient, IHeadlessB2BOrganizationClient, IHeadlessB2BOTPsClient, IHeadlessB2BTOTPsClient, IHeadlessB2BSessionClient, IHeadlessB2BSSOClient, IHeadlessB2BRecoveryCodesClient, IHeadlessB2BRBACClient, StytchClientOptions, IHeadlessB2BPasswordClient, Callbacks, StyleConfig, StytchB2BUIConfig } from "@stytch/core/public";
741
2
  /**
742
3
  * A headless client used for invoking Stytch's B2B APIs.
743
4
  * The Stytch Headless Client can be used as a drop-in solution for authentication and session management.
@@ -805,9 +66,9 @@ declare class StytchB2BUIClient extends StytchB2BHeadlessClient {
805
66
  */
806
67
  mount({ elementId, styles, callbacks, config }: {
807
68
  elementId: string;
808
- styles?: StyleConfig$0;
809
- callbacks?: Callbacks$0;
810
- config: StytchB2BUIConfig$0;
69
+ styles?: StyleConfig;
70
+ callbacks?: Callbacks;
71
+ config: StytchB2BUIConfig;
811
72
  }): void;
812
73
  }
813
74
  export { StytchB2BUIClient };