@mitralab.io/platform-sdk 1.7.0 → 1.8.0-beta.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.
- package/CHANGELOG.md +63 -0
- package/README.md +53 -4
- package/dist/index.cjs +632 -48
- package/dist/index.d.cts +340 -7
- package/dist/index.d.ts +340 -7
- package/dist/index.js +635 -51
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -38,6 +38,8 @@ interface RequestOptions extends Omit<TransportRequestOptions, 'method'> {
|
|
|
38
38
|
params?: Record<string, QueryParamValue>;
|
|
39
39
|
/** @internal Flag to prevent infinite retry loops on 401 */
|
|
40
40
|
isRetry?: boolean;
|
|
41
|
+
/** Lets the request outlive the page that sent it, as `fetch` `keepalive` does. */
|
|
42
|
+
keepalive?: boolean;
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
45
|
* HTTP client for making authenticated API requests.
|
|
@@ -247,6 +249,47 @@ interface EmailCodeRequestResult {
|
|
|
247
249
|
/** How long to wait before offering to send another message. */
|
|
248
250
|
resendAfterSeconds: number;
|
|
249
251
|
}
|
|
252
|
+
/** Options for `auth.requestPasswordReset()`. */
|
|
253
|
+
interface PasswordResetOptions {
|
|
254
|
+
/** Defaults to the browser language, and to `pt-BR` when that is neither. */
|
|
255
|
+
language?: EmailCodeLanguage;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* What IAM accepted for a reset. Neutral like {@link EmailCodeRequestResult}:
|
|
259
|
+
* it says nothing about whether the address has an account.
|
|
260
|
+
*/
|
|
261
|
+
interface PasswordResetRequestResult {
|
|
262
|
+
/** How long to wait before offering to send another message. */
|
|
263
|
+
resendAfterSeconds: number;
|
|
264
|
+
}
|
|
265
|
+
/** The address to create a password for, and the language of the message with the code. */
|
|
266
|
+
type PasswordSignUpRequest = EmailCodeRequest;
|
|
267
|
+
/** What IAM accepted for a password sign-up, as neutral as {@link EmailCodeRequestResult}. */
|
|
268
|
+
type PasswordSignUpRequestResult = EmailCodeRequestResult;
|
|
269
|
+
/** The code the person read in the message, and the password they chose. */
|
|
270
|
+
interface PasswordSignUpCompletion {
|
|
271
|
+
/** From `auth.startPasswordSignUp()`. */
|
|
272
|
+
receipt: string;
|
|
273
|
+
/** The six digits sent to the address. */
|
|
274
|
+
code: string;
|
|
275
|
+
password: string;
|
|
276
|
+
}
|
|
277
|
+
/** The password to replace, and the new one. */
|
|
278
|
+
interface PasswordChange {
|
|
279
|
+
/**
|
|
280
|
+
* Required by IAM whenever the account already has a password. Only an
|
|
281
|
+
* account that never had one, such as one born from the email code, goes
|
|
282
|
+
* without it.
|
|
283
|
+
*/
|
|
284
|
+
currentPassword?: string;
|
|
285
|
+
newPassword: string;
|
|
286
|
+
}
|
|
287
|
+
/** The token from the reset link, and the new password. */
|
|
288
|
+
interface PasswordResetConfirmation {
|
|
289
|
+
/** From `auth.readPasswordResetToken()`. */
|
|
290
|
+
token: string;
|
|
291
|
+
newPassword: string;
|
|
292
|
+
}
|
|
250
293
|
/** The code the person read in the message, against the request that sent it. */
|
|
251
294
|
interface EmailCodeVerification {
|
|
252
295
|
receipt: string;
|
|
@@ -306,7 +349,7 @@ interface AuthModuleOptions {
|
|
|
306
349
|
/**
|
|
307
350
|
* Authentication module for managing user sessions.
|
|
308
351
|
*
|
|
309
|
-
* Handles Google and Microsoft SSO, email sign-in, trusted session adoption, sign-out,
|
|
352
|
+
* Handles Google and Microsoft SSO, email and password sign-in, trusted session adoption, sign-out,
|
|
310
353
|
* and automatic token refresh.
|
|
311
354
|
* Auth state is persisted to localStorage with key `mitra_auth_{appId}`
|
|
312
355
|
* and restored on page reload.
|
|
@@ -334,7 +377,9 @@ declare class AuthModule {
|
|
|
334
377
|
private readonly googleAuth;
|
|
335
378
|
private readonly microsoftAuth;
|
|
336
379
|
private readonly emailAuth;
|
|
380
|
+
private readonly passwordAuth;
|
|
337
381
|
private readonly emailCode;
|
|
382
|
+
private readonly passwordForm;
|
|
338
383
|
private brand;
|
|
339
384
|
constructor(appId: string, iamBaseUrl: string, options?: AuthModuleOptions);
|
|
340
385
|
/** The currently authenticated user, or null. */
|
|
@@ -359,7 +404,10 @@ declare class AuthModule {
|
|
|
359
404
|
get allTokens(): AllTokens | null;
|
|
360
405
|
/** Whether a user is currently authenticated (local check, not server-validated). */
|
|
361
406
|
get isAuthenticated(): boolean;
|
|
362
|
-
/**
|
|
407
|
+
/**
|
|
408
|
+
* @deprecated Use signInWithPassword(), which opens the Mitra auth page,
|
|
409
|
+
* signInWithPasswordForm() in an app with the form mode on, signInWithEmail() or SSO.
|
|
410
|
+
*/
|
|
363
411
|
signIn(_credentials: SignInCredentials): Promise<User>;
|
|
364
412
|
/**
|
|
365
413
|
* Signs in with Google SSO.
|
|
@@ -555,11 +603,287 @@ declare class AuthModule {
|
|
|
555
603
|
* `MAGIC_LINK_INVALID` when the link belongs here but cannot be used.
|
|
556
604
|
*/
|
|
557
605
|
completeEmailSignInRedirect(): Promise<User | null>;
|
|
558
|
-
/**
|
|
606
|
+
/**
|
|
607
|
+
* @deprecated Use signUpWithPassword(), which opens the Mitra auth page,
|
|
608
|
+
* startPasswordSignUp() in an app with the form mode on, signInWithEmail() or SSO.
|
|
609
|
+
*/
|
|
559
610
|
signUp(_data: SignUpData): Promise<User>;
|
|
611
|
+
/**
|
|
612
|
+
* Signs in with email and password, typed into the Mitra auth page in a popup.
|
|
613
|
+
* The password never reaches the app's code: the page sends it to IAM and
|
|
614
|
+
* hands back a single-use exchange code, redeemed like the email sign-in.
|
|
615
|
+
*
|
|
616
|
+
* Offer it only when `mitra.passwordLoginEnabled` is `true`, which needs an
|
|
617
|
+
* app whose accounts are its own (exclusive login mode). Call it straight
|
|
618
|
+
* from the click handler, before any `await`, or the browser blocks the popup.
|
|
619
|
+
*
|
|
620
|
+
* @returns The authenticated and hydrated user.
|
|
621
|
+
* @throws {MitraApiError} When IAM rejects the exchange code.
|
|
622
|
+
* @throws {Error} When the browser blocks or cancels the popup, the flow times
|
|
623
|
+
* out, or the response fails origin, source, state, or shape validation. Wrong
|
|
624
|
+
* credentials are answered on the auth page itself, not here.
|
|
625
|
+
*
|
|
626
|
+
* @example
|
|
627
|
+
* ```typescript
|
|
628
|
+
* const user = await mitra.auth.signInWithPassword();
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
signInWithPassword(): Promise<User>;
|
|
632
|
+
/**
|
|
633
|
+
* Creates a password for an app account, on the Mitra auth page in a popup:
|
|
634
|
+
* the page asks for the address, sends a code to it to prove the mailbox is
|
|
635
|
+
* the person's, and takes the password with that code. The person ends signed
|
|
636
|
+
* in, as with {@link signInWithPassword}.
|
|
637
|
+
*
|
|
638
|
+
* @returns The authenticated and hydrated user.
|
|
639
|
+
* @throws The same errors as {@link signInWithPassword}.
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* ```typescript
|
|
643
|
+
* const user = await mitra.auth.signUpWithPassword();
|
|
644
|
+
* ```
|
|
645
|
+
*/
|
|
646
|
+
signUpWithPassword(): Promise<User>;
|
|
647
|
+
/**
|
|
648
|
+
* Changes the password of the signed-in person, on the Mitra auth page in a
|
|
649
|
+
* popup. The page asks for the current and the new password itself, so the
|
|
650
|
+
* app never sees either one.
|
|
651
|
+
*
|
|
652
|
+
* The page acts on this session, so it asks for the access token once it
|
|
653
|
+
* loads, and the SDK answers with `postMessage` to the auth page origin only:
|
|
654
|
+
* the token never goes in the popup URL.
|
|
655
|
+
*
|
|
656
|
+
* IAM ends every session of the account when the password changes, this one
|
|
657
|
+
* included, so the page signs in again with the new password and hands back a
|
|
658
|
+
* new session, which replaces the current one.
|
|
659
|
+
*
|
|
660
|
+
* When the change goes through but that new sign-in fails, the call rejects
|
|
661
|
+
* with `PASSWORD_CHANGED_SIGN_IN_AGAIN` and the local session is cleared,
|
|
662
|
+
* since IAM already ended it: send the person to sign in with the new password.
|
|
663
|
+
*
|
|
664
|
+
* @returns The user of the new session.
|
|
665
|
+
* @throws {MitraApiError} `401` when nobody is signed in, and
|
|
666
|
+
* `PASSWORD_CHANGED_SIGN_IN_AGAIN` (status `401`) as above.
|
|
667
|
+
* @throws The same errors as {@link signInWithPassword}, and an error when the
|
|
668
|
+
* session ends while the popup is open.
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* ```typescript
|
|
672
|
+
* await mitra.auth.changePassword();
|
|
673
|
+
* ```
|
|
674
|
+
*/
|
|
675
|
+
changePassword(): Promise<User>;
|
|
676
|
+
/**
|
|
677
|
+
* Asks IAM to email a link to set a new password. Only the address goes.
|
|
678
|
+
* Where the link opens depends on the app's mode of the password login: with
|
|
679
|
+
* the Mitra auth page, the default, the new password is typed there; with the
|
|
680
|
+
* form in the app itself, the link opens `/reset-password` on this app's
|
|
681
|
+
* origin, which reads it with {@link readPasswordResetToken} and finishes
|
|
682
|
+
* with {@link confirmPasswordReset}.
|
|
683
|
+
*
|
|
684
|
+
* IAM answers the same whether or not the address has an account, so this
|
|
685
|
+
* resolves without saying which.
|
|
686
|
+
*
|
|
687
|
+
* @param email - The address of the account.
|
|
688
|
+
* @param options - The language of the message.
|
|
689
|
+
* @returns How long the application should wait before offering to resend.
|
|
690
|
+
* @throws {MitraApiError} `RATE_LIMITED` when this address asked too often,
|
|
691
|
+
* and `RATE_LIMIT_EXCEEDED` when this network did, both with
|
|
692
|
+
* `retryAfterSeconds` when IAM sends it.
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* ```typescript
|
|
696
|
+
* const { resendAfterSeconds } = await mitra.auth.requestPasswordReset('person@example.com');
|
|
697
|
+
* ```
|
|
698
|
+
*/
|
|
699
|
+
requestPasswordReset(email: string, options?: PasswordResetOptions): Promise<PasswordResetRequestResult>;
|
|
700
|
+
/**
|
|
701
|
+
* The password goes through the app's code. Do not store it, do not log it
|
|
702
|
+
* and do not send it anywhere other than this method. The safer default is
|
|
703
|
+
* signInWithPassword(), which uses the Mitra auth page.
|
|
704
|
+
*
|
|
705
|
+
* Works only when the app has the "form in the app itself" mode of the
|
|
706
|
+
* password login turned on. Otherwise IAM refuses it with
|
|
707
|
+
* `PASSWORD_FORM_NOT_ENABLED` (status `403`). Browser only.
|
|
708
|
+
*
|
|
709
|
+
* Signs in with the address and password typed into the app's own form.
|
|
710
|
+
*
|
|
711
|
+
* @returns The authenticated and hydrated user.
|
|
712
|
+
* @throws {MitraApiError} `INVALID_CREDENTIALS` (status `401`) for a wrong
|
|
713
|
+
* address or password, a locked account or one without a password, all
|
|
714
|
+
* answered alike, `SIGNUP_NOT_ALLOWED` (status `403`) when the account lost
|
|
715
|
+
* its access to an app that takes no new accounts, `RATE_LIMIT_EXCEEDED`
|
|
716
|
+
* (status `429`, with `retryAfterSeconds` when IAM sends it) when this
|
|
717
|
+
* network called the password routes too often or IAM is at its limit of
|
|
718
|
+
* passwords being hashed, so wait `retryAfterSeconds`, and
|
|
719
|
+
* `PASSWORD_FORM_NOT_ENABLED` as above.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
* ```typescript
|
|
723
|
+
* const user = await mitra.auth.signInWithPasswordForm({ email, password });
|
|
724
|
+
* ```
|
|
725
|
+
*/
|
|
726
|
+
signInWithPasswordForm(credentials: SignInCredentials): Promise<User>;
|
|
727
|
+
/**
|
|
728
|
+
* The password goes through the app's code. Do not store it, do not log it
|
|
729
|
+
* and do not send it anywhere other than this method. The safer default is
|
|
730
|
+
* signInWithPassword(), which uses the Mitra auth page.
|
|
731
|
+
*
|
|
732
|
+
* First step of creating a password from the app's own form: IAM emails a
|
|
733
|
+
* six-digit code to the address, to prove the mailbox is the person's. No
|
|
734
|
+
* password goes in this step, which IAM takes in either mode of the app; the
|
|
735
|
+
* "form in the app itself" mode is required at {@link completePasswordSignUp},
|
|
736
|
+
* where the password goes. Browser only.
|
|
737
|
+
*
|
|
738
|
+
* IAM answers the same whether or not the address has an account, so this
|
|
739
|
+
* resolves without saying which.
|
|
740
|
+
*
|
|
741
|
+
* @param request - The address, and the language of the message.
|
|
742
|
+
* @returns The receipt that names this request, and the resend delay.
|
|
743
|
+
* @throws {MitraApiError} `RATE_LIMITED` (with `retryAfterSeconds`) when this
|
|
744
|
+
* address asked too often, and `RATE_LIMIT_EXCEEDED` (status `429`, with
|
|
745
|
+
* `retryAfterSeconds` when IAM sends it) when this network called the
|
|
746
|
+
* password routes too often.
|
|
747
|
+
*
|
|
748
|
+
* @example
|
|
749
|
+
* ```typescript
|
|
750
|
+
* const { receipt, resendAfterSeconds } = await mitra.auth.startPasswordSignUp({ email });
|
|
751
|
+
* ```
|
|
752
|
+
*/
|
|
753
|
+
startPasswordSignUp(request: PasswordSignUpRequest): Promise<PasswordSignUpRequestResult>;
|
|
754
|
+
/**
|
|
755
|
+
* The password goes through the app's code. Do not store it, do not log it
|
|
756
|
+
* and do not send it anywhere other than this method. The safer default is
|
|
757
|
+
* signInWithPassword(), which uses the Mitra auth page.
|
|
758
|
+
*
|
|
759
|
+
* Works only when the app has the "form in the app itself" mode of the
|
|
760
|
+
* password login turned on. Otherwise IAM refuses it with
|
|
761
|
+
* `PASSWORD_FORM_NOT_ENABLED` (status `403`). Browser only.
|
|
762
|
+
*
|
|
763
|
+
* Second step of {@link startPasswordSignUp}: the code from the message and
|
|
764
|
+
* the chosen password. The person ends signed in, as with
|
|
765
|
+
* {@link signInWithPasswordForm}.
|
|
766
|
+
*
|
|
767
|
+
* @param completion - The receipt, the code and the password.
|
|
768
|
+
* @returns The authenticated and hydrated user.
|
|
769
|
+
* @throws {MitraApiError} `INVALID_CODE` when the code does not match or the
|
|
770
|
+
* request expired, `MAGIC_LINK_USED` when it was already completed,
|
|
771
|
+
* `PASSWORD_ALREADY_SET` when the account has a password (the way to replace
|
|
772
|
+
* it is the reset), `SSO_ACCOUNT` (status `409`) when the account signs in
|
|
773
|
+
* with Google or Microsoft, `SIGNUP_NOT_ALLOWED` when the app takes no new
|
|
774
|
+
* accounts, `WEAK_PASSWORD` (status `400`) with the rule the password broke,
|
|
775
|
+
* `RATE_LIMIT_EXCEEDED` (status `429`, with `retryAfterSeconds` when IAM
|
|
776
|
+
* sends it) when this network called the password routes too often or IAM is
|
|
777
|
+
* at its limit of passwords being hashed, so wait `retryAfterSeconds`, and
|
|
778
|
+
* `PASSWORD_FORM_NOT_ENABLED` as above.
|
|
779
|
+
*
|
|
780
|
+
* @example
|
|
781
|
+
* ```typescript
|
|
782
|
+
* const user = await mitra.auth.completePasswordSignUp({ receipt, code, password });
|
|
783
|
+
* ```
|
|
784
|
+
*/
|
|
785
|
+
completePasswordSignUp(completion: PasswordSignUpCompletion): Promise<User>;
|
|
786
|
+
/**
|
|
787
|
+
* The password goes through the app's code. Do not store it, do not log it
|
|
788
|
+
* and do not send it anywhere other than this method. The safer default is
|
|
789
|
+
* signInWithPassword(), which uses the Mitra auth page.
|
|
790
|
+
*
|
|
791
|
+
* Works only when the app has the "form in the app itself" mode of the
|
|
792
|
+
* password login turned on. Otherwise IAM refuses it with
|
|
793
|
+
* `PASSWORD_FORM_NOT_ENABLED` (status `403`). Browser only.
|
|
794
|
+
*
|
|
795
|
+
* Changes the password of the signed-in person from the app's own form. IAM
|
|
796
|
+
* ends every session of the account when the password changes, this one
|
|
797
|
+
* included, so the SDK signs in again with the address of this session and
|
|
798
|
+
* the new password, and that session replaces the current one.
|
|
799
|
+
*
|
|
800
|
+
* When the change goes through but that new sign-in fails, the call rejects
|
|
801
|
+
* with `PASSWORD_CHANGED_SIGN_IN_AGAIN` and the local session is cleared,
|
|
802
|
+
* since IAM already ended it: send the person to sign in with the new password.
|
|
803
|
+
*
|
|
804
|
+
* @param change - The current password, required whenever the account
|
|
805
|
+
* already has one, and the new one.
|
|
806
|
+
* @returns The user of the new session.
|
|
807
|
+
* @throws {MitraApiError} `401` when nobody is signed in,
|
|
808
|
+
* `PASSWORD_CHANGED_SIGN_IN_AGAIN` (status `401`) as above,
|
|
809
|
+
* `INVALID_CREDENTIALS` (status `401`) for a wrong current password,
|
|
810
|
+
* `CURRENT_PASSWORD_REQUIRED` and `WEAK_PASSWORD` (status `400`),
|
|
811
|
+
* `SSO_ACCOUNT` (status `409`) when the account signs in with Google or
|
|
812
|
+
* Microsoft, `RATE_LIMIT_EXCEEDED` (status `429`, with `retryAfterSeconds`
|
|
813
|
+
* when IAM sends it) when this network called the password routes too often
|
|
814
|
+
* or IAM is at its limit of passwords being hashed, so wait
|
|
815
|
+
* `retryAfterSeconds`, and `PASSWORD_FORM_NOT_ENABLED` as above.
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* ```typescript
|
|
819
|
+
* await mitra.auth.changePasswordForm({ currentPassword, newPassword });
|
|
820
|
+
* ```
|
|
821
|
+
*/
|
|
822
|
+
changePasswordForm(change: PasswordChange): Promise<User>;
|
|
823
|
+
/**
|
|
824
|
+
* The password goes through the app's code. Do not store it, do not log it
|
|
825
|
+
* and do not send it anywhere other than this method. The safer default is
|
|
826
|
+
* signInWithPassword(), which uses the Mitra auth page.
|
|
827
|
+
*
|
|
828
|
+
* The reset token is single use and works as a credential until it is spent:
|
|
829
|
+
* do not log it either.
|
|
830
|
+
*
|
|
831
|
+
* Reads the token of a password reset link that landed on this app, and
|
|
832
|
+
* removes the fragment from the URL so the token does not stay in the
|
|
833
|
+
* history. With the form in the app itself turned on, IAM sends the link to
|
|
834
|
+
* `/reset-password#resetToken=...` on the origin the reset was asked from:
|
|
835
|
+
* call this when that route loads, then {@link confirmPasswordReset}.
|
|
836
|
+
*
|
|
837
|
+
* Nothing is sent to IAM here, and a URL without the link is left as it is.
|
|
838
|
+
* Browser only.
|
|
839
|
+
*
|
|
840
|
+
* @returns The token, or `null` when the URL carries none.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```typescript
|
|
844
|
+
* const token = mitra.auth.readPasswordResetToken();
|
|
845
|
+
* ```
|
|
846
|
+
*/
|
|
847
|
+
readPasswordResetToken(): string | null;
|
|
848
|
+
/**
|
|
849
|
+
* The password goes through the app's code. Do not store it, do not log it
|
|
850
|
+
* and do not send it anywhere other than this method. The safer default is
|
|
851
|
+
* signInWithPassword(), which uses the Mitra auth page.
|
|
852
|
+
*
|
|
853
|
+
* Works only when the app has the "form in the app itself" mode of the
|
|
854
|
+
* password login turned on. Otherwise IAM refuses it with
|
|
855
|
+
* `PASSWORD_FORM_NOT_ENABLED` (status `403`). Browser only.
|
|
856
|
+
*
|
|
857
|
+
* Sets the new password with the token from the reset link. The link is
|
|
858
|
+
* single use, and IAM ends every session of the account, so the person signs
|
|
859
|
+
* in afterwards with the new password; this method signs nobody in.
|
|
860
|
+
*
|
|
861
|
+
* @param confirmation - The token from {@link readPasswordResetToken} and the
|
|
862
|
+
* new password.
|
|
863
|
+
* @throws {MitraApiError} `RESET_TOKEN_USED` or `RESET_TOKEN_EXPIRED` (status
|
|
864
|
+
* `409`) when the link can no longer be used; a token IAM does not know also
|
|
865
|
+
* answers `RESET_TOKEN_EXPIRED`. Also `WEAK_PASSWORD` (status `400`),
|
|
866
|
+
* `SSO_ACCOUNT` (status `409`) when the account signs in with Google or
|
|
867
|
+
* Microsoft, `RATE_LIMIT_EXCEEDED` (status `429`, with `retryAfterSeconds`
|
|
868
|
+
* when IAM sends it) when this network called the password routes too often
|
|
869
|
+
* or IAM is at its limit of passwords being hashed, so wait
|
|
870
|
+
* `retryAfterSeconds`, and `PASSWORD_FORM_NOT_ENABLED` as above.
|
|
871
|
+
*
|
|
872
|
+
* @example
|
|
873
|
+
* ```typescript
|
|
874
|
+
* await mitra.auth.confirmPasswordReset({ token, newPassword });
|
|
875
|
+
* ```
|
|
876
|
+
*/
|
|
877
|
+
confirmPasswordReset(confirmation: PasswordResetConfirmation): Promise<void>;
|
|
560
878
|
/**
|
|
561
879
|
* Signs out the current user, clearing all auth state and localStorage.
|
|
562
880
|
*
|
|
881
|
+
* In an app whose accounts are its own, the session also ends on the server:
|
|
882
|
+
* the refresh token is sent to IAM's logout, so it can no longer be renewed.
|
|
883
|
+
* The local state is cleared right away whatever IAM answers, and the request
|
|
884
|
+
* survives a navigation to `redirectUrl`. The access token already issued
|
|
885
|
+
* stays valid until it expires.
|
|
886
|
+
*
|
|
563
887
|
* @param redirectUrl - Optional URL to navigate to after sign-out.
|
|
564
888
|
*
|
|
565
889
|
* @example
|
|
@@ -772,6 +1096,8 @@ declare class AuthModule {
|
|
|
772
1096
|
* ```
|
|
773
1097
|
*/
|
|
774
1098
|
onAuthStateChange(callback: AuthStateChangeCallback): () => void;
|
|
1099
|
+
/** Best effort: the person asked to leave, and that already happened locally. */
|
|
1100
|
+
private endServerSession;
|
|
775
1101
|
private doRefresh;
|
|
776
1102
|
private establishSession;
|
|
777
1103
|
private setAuthState;
|
|
@@ -955,8 +1281,9 @@ interface MitraClient {
|
|
|
955
1281
|
/**
|
|
956
1282
|
* Initializes the client by resolving app config from the server.
|
|
957
1283
|
*
|
|
958
|
-
* Fetches the compatibility dataSourceId, allowSignup, emailLoginEnabled,
|
|
959
|
-
* the brand `requestEmailCode()` sends with, from
|
|
1284
|
+
* Fetches the compatibility dataSourceId, allowSignup, emailLoginEnabled,
|
|
1285
|
+
* passwordLoginEnabled, and the brand `requestEmailCode()` sends with, from
|
|
1286
|
+
* the public app info endpoint.
|
|
960
1287
|
*
|
|
961
1288
|
* Safe to call multiple times. Subsequent calls are no-ops.
|
|
962
1289
|
*
|
|
@@ -1049,6 +1376,12 @@ interface MitraClient {
|
|
|
1049
1376
|
* server does not answer the field.
|
|
1050
1377
|
*/
|
|
1051
1378
|
readonly emailLoginEnabled: boolean;
|
|
1379
|
+
/**
|
|
1380
|
+
* Whether this app offers sign-in by email and password, which only an app
|
|
1381
|
+
* whose accounts are its own can. Defaults to `false` before `init()` is
|
|
1382
|
+
* called, and stays `false` when the server does not answer the field.
|
|
1383
|
+
*/
|
|
1384
|
+
readonly passwordLoginEnabled: boolean;
|
|
1052
1385
|
/**
|
|
1053
1386
|
* The configuration used to create this client.
|
|
1054
1387
|
*/
|
|
@@ -1065,7 +1398,7 @@ interface MitraClient {
|
|
|
1065
1398
|
* - **queries**: Custom query management and execution
|
|
1066
1399
|
*
|
|
1067
1400
|
* After creating the client, call `init()` to resolve the app's public config
|
|
1068
|
-
* (dataSourceId, allowSignup, emailLoginEnabled) automatically from the server.
|
|
1401
|
+
* (dataSourceId, allowSignup, emailLoginEnabled, passwordLoginEnabled) automatically from the server.
|
|
1069
1402
|
*
|
|
1070
1403
|
* @param config - Configuration options for the client.
|
|
1071
1404
|
* @returns A configured MitraClient instance.
|
|
@@ -1271,4 +1604,4 @@ type StopServerFunctionExecutionResponse = LegacyTypes.StopServerFunctionExecuti
|
|
|
1271
1604
|
/** @deprecated Legacy compatibility type. */
|
|
1272
1605
|
type UpdateRecordOptions = LegacyTypes.UpdateRecordOptions;
|
|
1273
1606
|
|
|
1274
|
-
export { type AgentChat, type AgentCredentialProvider, type AgentCredentialStatus, type AgentCredentialsModule, type AgentDeltaEvent, type AgentDeviceProvider, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentOAuthProvider, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AllTokens, type AuthAgentCredentialResult, type AuthPageSignInOptions, type BackofficeToken, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type EmailCodeLanguage, type EmailCodeRequest, type EmailCodeRequestResult, type EmailCodeVerification, type EmailSignInOptions, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GoogleSignInOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type MicrosoftSignInOptions, MitraApiError, type MitraClient, type MitraClientConfig, type MitraConfig, type MitraInstance, type MitraSpaceToken, type PatchRecordOptions, type PlatformSessionTokens, type QueuedItem, type RenameAgentChatResult, type SendOptions, type SignInCredentials, type SignUpData, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type User, createClient, exchangeSsoCodeMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra };
|
|
1607
|
+
export { type AgentChat, type AgentCredentialProvider, type AgentCredentialStatus, type AgentCredentialsModule, type AgentDeltaEvent, type AgentDeviceProvider, type AgentErrorEvent, type AgentMessage, type AgentModel, type AgentOAuthProvider, type AgentProvider, type AgentQueueChangeEvent, type AgentRawEvent, type AgentStatusChangeEvent, type AgentTaskCreatedEvent, type AgentTaskEventMap, type AgentTaskEventName, type AgentTaskSession, type AgentTaskStatus, type AgentTaskTransport, type AgentTimelineItem, type AgentToolEvent, type AgentTurnEndEvent, type AgentType, type AllTokens, type AuthAgentCredentialResult, type AuthPageSignInOptions, type BackofficeToken, type CallIntegrationOptions, type CallIntegrationResponse, type ChatManageAction, type ConnectAgentCredentialResult, type CreateRecordOptions, type CreateRecordsBatchOptions, type CredentialAction, type DeleteAgentChatResult, type DeleteRecordOptions, type DeviceAuthAgentCredentialResult, type EmailCodeLanguage, type EmailCodeRequest, type EmailCodeRequestResult, type EmailCodeVerification, type EmailSignInOptions, type ExecutePublicServerFunctionAsyncResponse, type ExecutePublicServerFunctionOptions, type ExecutePublicServerFunctionResponse, type ExecuteServerFunctionAsyncOptions, type ExecuteServerFunctionAsyncResponse, type ExecuteServerFunctionOptions, type ExecuteServerFunctionResponse, type GetAgentTaskCreateOptions, type GetAgentTaskOpenOptions, type GetAgentTaskOptions, type GetPublicServerFunctionExecutionOptions, type GetPublicServerFunctionExecutionResponse, type GetRecordOptions, type GoogleSignInOptions, type IntegrationResponse, type ListAgentModelsResult, type ListAgentProvidersResult, type ListIntegrationsOptions, type ListRecordsOptions, type ListRecordsResponse, type LoginOptions, type LoginResponse, type ManageAgentChatDeleteOptions, type ManageAgentChatListOptions, type ManageAgentChatOptions, type ManageAgentChatRenameOptions, type ManageAgentCredentialOptions, type MicrosoftSignInOptions, MitraApiError, type MitraClient, type MitraClientConfig, type MitraConfig, type MitraInstance, type MitraSpaceToken, type PasswordChange, type PasswordResetConfirmation, type PasswordResetOptions, type PasswordResetRequestResult, type PasswordSignUpCompletion, type PasswordSignUpRequest, type PasswordSignUpRequestResult, type PatchRecordOptions, type PlatformSessionTokens, type QueuedItem, type RenameAgentChatResult, type SendOptions, type SignInCredentials, type SignUpData, type StopServerFunctionExecutionOptions, type StopServerFunctionExecutionResponse, type UpdateRecordOptions, type User, createClient, exchangeSsoCodeMitra, loginMitra, loginWithGoogleMitra, loginWithMicrosoftMitra };
|