@stytch/vanilla-js 2.2.2 → 3.0.1

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