@getauthui/core 0.1.0

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,743 @@
1
+ import { Client } from 'appwrite';
2
+ import { CSSResult } from 'lit';
3
+ import { LitElement } from 'lit';
4
+ import { Models } from 'appwrite';
5
+ import { nothing } from 'lit';
6
+ import { TemplateResult } from 'lit';
7
+
8
+ /**
9
+ * Single source of truth for the widget. Wraps the Appwrite Account service,
10
+ * tracks the signed-in user and broadcasts changes on `window` as `authui:change`.
11
+ */
12
+ export declare class AuthStore {
13
+ private client;
14
+ private account;
15
+ private config;
16
+ private state;
17
+ private listeners;
18
+ private refreshPromise;
19
+ /** Configure the Appwrite client. Safe to call more than once; the last call wins. */
20
+ configure(config: AuthUIConfig): void;
21
+ get isConfigured(): boolean;
22
+ getConfig(): AuthUIConfig | null;
23
+ /** The configured Appwrite client, for apps that want to reuse it. */
24
+ getClient(): Client | null;
25
+ getStrings(): AuthUIStrings;
26
+ getState(): AuthUIState;
27
+ get user(): Models.User<Models.Preferences> | null;
28
+ on<K extends AuthUIEventName>(event: K, listener: Listener<K>): () => void;
29
+ private emit;
30
+ private setState;
31
+ private fail;
32
+ private acct;
33
+ /** Re-fetch the current user and derive status. */
34
+ refresh(): Promise<void>;
35
+ private afterSignIn;
36
+ signInWithEmailPassword(email: string, password: string): Promise<void>;
37
+ signUp(email: string, password: string, name?: string): Promise<void>;
38
+ signInAnonymously(): Promise<void>;
39
+ /** Redirects the browser to the provider. Never resolves in a browser. */
40
+ signInWithOAuth(provider: OAuthProviderName): void;
41
+ sendMagicUrl(email: string): Promise<Models.Token>;
42
+ sendEmailOtp(email: string): Promise<Models.Token>;
43
+ sendPhoneOtp(phone: string): Promise<Models.Token>;
44
+ /** Redeem any token secret (email OTP, SMS OTP, magic URL, OAuth token). */
45
+ signInWithToken(userId: string, secret: string): Promise<void>;
46
+ createMfaChallenge(factor: MfaFactor): Promise<Models.MfaChallenge>;
47
+ /** Verify a challenge. Completes a pending sign in, or acts as a step-up for protected actions. */
48
+ completeMfaChallenge(challengeId: string, otp: string, opts?: {
49
+ signIn?: boolean;
50
+ }): Promise<void>;
51
+ listMfaFactors(): Promise<Models.MfaFactors>;
52
+ setMfaEnabled(enabled: boolean): Promise<void>;
53
+ addAuthenticator(): Promise<Models.MfaType>;
54
+ verifyAuthenticator(otp: string): Promise<void>;
55
+ /** Requires a recent MFA challenge (server rejects with user_challenge_required otherwise). */
56
+ removeAuthenticator(): Promise<void>;
57
+ createRecoveryCodes(): Promise<string[]>;
58
+ /** Requires a recent MFA challenge. */
59
+ regenerateRecoveryCodes(): Promise<string[]>;
60
+ /** Requires a recent MFA challenge. */
61
+ getRecoveryCodes(): Promise<string[]>;
62
+ sendPasswordRecovery(email: string): Promise<void>;
63
+ completePasswordRecovery(userId: string, secret: string, password: string): Promise<void>;
64
+ signOut(sessionId?: string): Promise<void>;
65
+ signOutEverywhere(): Promise<void>;
66
+ listSessions(): Promise<Models.Session[]>;
67
+ listIdentities(): Promise<Models.Identity[]>;
68
+ deleteIdentity(identityId: string): Promise<void>;
69
+ listLogs(): Promise<Models.Log[]>;
70
+ updateName(name: string): Promise<void>;
71
+ updateEmail(email: string, password: string): Promise<void>;
72
+ updatePhone(phone: string, password: string): Promise<void>;
73
+ updatePassword(password: string, oldPassword?: string): Promise<void>;
74
+ /** Turn an anonymous session into a full account. */
75
+ convertGuest(email: string, password: string, name?: string): Promise<void>;
76
+ sendEmailVerification(): Promise<void>;
77
+ sendPhoneVerification(): Promise<void>;
78
+ confirmPhoneVerification(otp: string): Promise<void>;
79
+ /** Blocks the account and ends the session. Appwrite keeps the record so an admin can restore it. */
80
+ deleteAccount(): Promise<void>;
81
+ /** Build the URL Appwrite should send the user back to for a given flow. */
82
+ redirectUrl(action: string): string;
83
+ setPending(pending: AuthUIPendingAction | null): void;
84
+ /**
85
+ * Finish a flow that arrived through the URL. Called automatically by `configure()`.
86
+ * Returns true when a redirect was handled.
87
+ */
88
+ handleRedirect(): Promise<boolean>;
89
+ private cleanUrl;
90
+ /** Test helper. */
91
+ reset(): void;
92
+ }
93
+
94
+ export declare const authStore: AuthStore;
95
+
96
+ /** Convenience namespace: `AuthUI.init({...}); AuthUI.open();` */
97
+ export declare const AuthUI: {
98
+ init: typeof init;
99
+ open: typeof open_2;
100
+ close: typeof close_2;
101
+ signOut: typeof signOut;
102
+ getUser: typeof getUser;
103
+ getState: typeof getState;
104
+ getClient: typeof getClient;
105
+ on: typeof on;
106
+ store: AuthStore;
107
+ };
108
+
109
+ /**
110
+ * Self-service account management: profile, password, MFA (authenticator app and
111
+ * recovery codes), sessions, connected OAuth identities, security log and account deletion.
112
+ */
113
+ export declare class AuthUIAccount extends AuthUIElement {
114
+ static styles: CSSResult[];
115
+ /** Set by <authui-modal>; hides the card chrome. */
116
+ embedded: boolean;
117
+ tab: Tab;
118
+ private active;
119
+ private busy;
120
+ private notice;
121
+ private errors;
122
+ private nameInput;
123
+ private emailInput;
124
+ private emailPassword;
125
+ private phoneInput;
126
+ private phonePassword;
127
+ private phoneCode;
128
+ private phoneCodeSent;
129
+ private guestName;
130
+ private oldPassword;
131
+ private newPassword;
132
+ private newPasswordConfirm;
133
+ private authenticator;
134
+ private authenticatorCode;
135
+ private factors;
136
+ private recoveryCodes;
137
+ private stepUp;
138
+ private stepUpCode;
139
+ private copied;
140
+ private sessions;
141
+ private identities;
142
+ private logs;
143
+ private logsSupported;
144
+ private confirmDelete;
145
+ connectedCallback(): void;
146
+ protected willUpdate(changed: Map<string, unknown>): void;
147
+ /** Lazily load data for the active tab once a user is available. */
148
+ private ensureLoaded;
149
+ private hydrate;
150
+ private get user();
151
+ private get isGuest();
152
+ private select;
153
+ /** Run an action with a busy key, surfacing errors under that key. Handles MFA step-up. */
154
+ private run;
155
+ private loadSessions;
156
+ private loadIdentities;
157
+ private loadLogs;
158
+ private factorsLoading;
159
+ private loadFactors;
160
+ private onUpdateName;
161
+ private onUpdateEmail;
162
+ private onUpdatePhone;
163
+ private onConvertGuest;
164
+ private onSendVerification;
165
+ private onSendPhoneVerification;
166
+ private onConfirmPhoneVerification;
167
+ private onChangePassword;
168
+ private onToggleMfa;
169
+ private onAddAuthenticator;
170
+ private onVerifyAuthenticator;
171
+ private onRemoveAuthenticator;
172
+ private onRecoveryCodes;
173
+ private onRegenerateRecoveryCodes;
174
+ private onCopyCodes;
175
+ private onStepUpFactor;
176
+ private onStepUpVerify;
177
+ private onDeleteSession;
178
+ private onSignOutAll;
179
+ private onDeleteIdentity;
180
+ private onDeleteAccount;
181
+ private bind;
182
+ protected render(): TemplateResult<1>;
183
+ private renderIdentity;
184
+ private renderTab;
185
+ private error;
186
+ private spinner;
187
+ private card;
188
+ private verifiedBadge;
189
+ private renderProfile;
190
+ private renderDanger;
191
+ private renderSecurity;
192
+ private renderMfaCard;
193
+ private renderRecoveryCard;
194
+ /** Inline MFA challenge shown when Appwrite demands a recent factor for a protected action. */
195
+ private renderStepUp;
196
+ private deviceIcon;
197
+ private renderSessions;
198
+ private renderConnections;
199
+ private renderActivity;
200
+ }
201
+
202
+ export declare interface AuthUIBranding {
203
+ /** Product name shown in headings. */
204
+ name?: string;
205
+ /** Logo URL rendered above the form. */
206
+ logo?: string;
207
+ /** Color scheme. "auto" follows prefers-color-scheme and an `html.dark` class. Default: "auto". */
208
+ theme?: AuthUITheme;
209
+ /** Corner radius scale. Default: "md". */
210
+ radius?: AuthUIRadius;
211
+ /** Any CSS color for primary buttons. Default: near-black / near-white. */
212
+ primary?: string;
213
+ /** Text color on primary buttons. */
214
+ primaryForeground?: string;
215
+ }
216
+
217
+ /**
218
+ * A button that opens the Auth UI modal.
219
+ *
220
+ * <authui-button>Sign in</authui-button>
221
+ * <authui-button view="sign-up" variant="outline">Create account</authui-button>
222
+ */
223
+ export declare class AuthUIButton extends AuthUIElement {
224
+ static styles: CSSResult[];
225
+ view: AuthUIView;
226
+ variant: "primary" | "brand" | "outline" | "secondary" | "ghost" | "link";
227
+ size: "sm" | "md" | "lg";
228
+ protected render(): TemplateResult<1>;
229
+ }
230
+
231
+ export declare interface AuthUIConfig {
232
+ /** Appwrite API endpoint, e.g. https://cloud.appwrite.io/v1 */
233
+ endpoint: string;
234
+ /** Appwrite project ID. */
235
+ project: string;
236
+ /**
237
+ * Absolute URL the user returns to after OAuth, magic URL, recovery and verification emails.
238
+ * Must be on a hostname registered as a web platform in your Appwrite project.
239
+ * Default: the current page without query string or hash.
240
+ */
241
+ redirectUrl?: string;
242
+ /** Where to navigate after a successful sign in. If omitted the page is not changed. */
243
+ successUrl?: string;
244
+ methods?: AuthUIMethods;
245
+ /** Show the "Sign up" option. Default: true. */
246
+ signUp?: boolean;
247
+ /** Ask for a display name during sign up. Default: true. */
248
+ requireName?: boolean;
249
+ /** Let users enroll and manage MFA from the account screen. Default: true. */
250
+ mfa?: boolean;
251
+ /** Request a security phrase for email OTP and magic URL. Default: true. */
252
+ securityPhrase?: boolean;
253
+ /** Extra OAuth scopes per provider. */
254
+ oauthScopes?: Partial<Record<OAuthProviderName, string[]>>;
255
+ branding?: AuthUIBranding;
256
+ legal?: AuthUILegal;
257
+ /** Override any UI string. */
258
+ strings?: Partial<AuthUIStrings>;
259
+ }
260
+
261
+ /**
262
+ * Declarative configuration. Drop it anywhere in the page:
263
+ *
264
+ * <authui-config endpoint="https://cloud.appwrite.io/v1" project="my-project"
265
+ * methods="email-password magic-url anonymous oauth:google oauth:github"></authui-config>
266
+ */
267
+ export declare class AuthUIConfigElement extends LitElement {
268
+ static styles: CSSResult;
269
+ endpoint: string;
270
+ project: string;
271
+ redirectUrl: string;
272
+ successUrl: string;
273
+ /** Space separated list, e.g. "email-password magic-url email-otp phone anonymous oauth:google". */
274
+ methods: string;
275
+ signUp: string;
276
+ requireName: string;
277
+ mfa: string;
278
+ securityPhrase: string;
279
+ name: string;
280
+ logo: string;
281
+ theme: string;
282
+ radius: string;
283
+ primary: string;
284
+ primaryForeground: string;
285
+ termsUrl: string;
286
+ privacyUrl: string;
287
+ connectedCallback(): void;
288
+ protected updated(): void;
289
+ private configure;
290
+ toConfig(): AuthUIConfig;
291
+ }
292
+
293
+ /**
294
+ * Base class for every Auth UI element: subscribes to the store, resolves theme
295
+ * and branding onto the host, and exposes `t()` for strings.
296
+ */
297
+ export declare class AuthUIElement extends LitElement {
298
+ static styles: CSSResult[];
299
+ protected auth: AuthUIState;
300
+ private unsubscribeStore;
301
+ private unsubscribeTheme;
302
+ connectedCallback(): void;
303
+ disconnectedCallback(): void;
304
+ protected get strings(): AuthUIStrings;
305
+ /** Translate a string key with optional `{placeholders}`. */
306
+ protected t(key: keyof AuthUIStrings, values?: Record<string, string | number>): string;
307
+ protected get config(): AuthUIConfig | null;
308
+ protected get productName(): string;
309
+ /** Push theme and branding from config onto the host element. */
310
+ protected applyBranding(): void;
311
+ /** Emit a composed custom event from this element. */
312
+ protected fire<T>(name: string, detail?: T): void;
313
+ }
314
+
315
+ declare interface AuthUIError {
316
+ message: string;
317
+ type: string;
318
+ code: number;
319
+ }
320
+
321
+ export declare type AuthUIEventMap = {
322
+ change: AuthUIState;
323
+ "signed-in": Models.User<Models.Preferences>;
324
+ "signed-out": undefined;
325
+ error: {
326
+ message: string;
327
+ type: string;
328
+ code: number;
329
+ };
330
+ };
331
+
332
+ export declare type AuthUIEventName = keyof AuthUIEventMap;
333
+
334
+ export declare interface AuthUILegal {
335
+ termsUrl?: string;
336
+ privacyUrl?: string;
337
+ }
338
+
339
+ export declare interface AuthUIMethods {
340
+ /** Email + password sign in and sign up. Default: true. */
341
+ emailPassword?: boolean;
342
+ /** Passwordless link sent by email. Default: false. */
343
+ magicUrl?: boolean;
344
+ /** Passwordless 6-digit code sent by email. Default: false. */
345
+ emailOtp?: boolean;
346
+ /** SMS one-time code. Default: false. */
347
+ phone?: boolean;
348
+ /** "Continue as guest" anonymous session. Default: false. */
349
+ anonymous?: boolean;
350
+ /** OAuth2 providers to show, in order. Default: []. */
351
+ oauth?: OAuthProviderName[];
352
+ }
353
+
354
+ /**
355
+ * Dialog host for the sign-in and account screens. Opens on `AuthUI.open()`, on
356
+ * `<authui-button>` clicks, and automatically when a redirect needs to finish
357
+ * (password reset link, failed OAuth attempt).
358
+ */
359
+ export declare class AuthUIModal extends AuthUIElement {
360
+ static styles: CSSResult[];
361
+ /** Whether the dialog is open. Reflects to an attribute. */
362
+ open: boolean;
363
+ /** Which screen to show. */
364
+ view: AuthUIView;
365
+ /** Close automatically after a successful sign in. Default: true. */
366
+ closeOnSuccess: boolean;
367
+ private handledPending;
368
+ private dialog?;
369
+ connectedCallback(): void;
370
+ disconnectedCallback(): void;
371
+ private onOpenEvent;
372
+ private onCloseEvent;
373
+ show(view?: AuthUIView): void;
374
+ hide(): void;
375
+ protected updated(changed: Map<string, unknown>): void;
376
+ private onSuccess;
377
+ private onInnerOpen;
378
+ private onBackdrop;
379
+ protected render(): TemplateResult<1>;
380
+ }
381
+
382
+ /** Something the widget must finish after a redirect, e.g. password reset. */
383
+ export declare type AuthUIPendingAction = {
384
+ type: "reset-password";
385
+ userId: string;
386
+ secret: string;
387
+ } | {
388
+ type: "verify-email";
389
+ userId: string;
390
+ secret: string;
391
+ } | {
392
+ type: "oauth-failed";
393
+ } | {
394
+ type: "notice";
395
+ message: string;
396
+ tone: "success" | "error" | "info";
397
+ };
398
+
399
+ export declare type AuthUIRadius = "none" | "sm" | "md" | "lg" | "xl" | "full";
400
+
401
+ /** Renders its children only while a user is signed in. */
402
+ export declare class AuthUISignedIn extends ConditionalElement {
403
+ protected shouldShow(status: AuthUIStatus): boolean;
404
+ }
405
+
406
+ /** Renders its children only while nobody is signed in (including while MFA is pending). */
407
+ export declare class AuthUISignedOut extends ConditionalElement {
408
+ protected shouldShow(status: AuthUIStatus): boolean;
409
+ }
410
+
411
+ /**
412
+ * The complete sign-in experience: OAuth, email + password, sign up, passwordless
413
+ * (magic URL, email OTP, SMS), guest sessions, password recovery and MFA challenges.
414
+ * Works standalone in the page or inside <authui-modal>.
415
+ */
416
+ export declare class AuthUISignIn extends AuthUIElement {
417
+ static styles: CSSResult[];
418
+ /** Initial screen. */
419
+ view: Step;
420
+ /** Set by <authui-modal>; hides the card chrome. */
421
+ embedded: boolean;
422
+ private step;
423
+ private busy;
424
+ private error;
425
+ private notice;
426
+ private showPassword;
427
+ private token;
428
+ private challenge;
429
+ private recovery;
430
+ private firstInput?;
431
+ private email;
432
+ private password;
433
+ private passwordConfirm;
434
+ private name;
435
+ private phone;
436
+ private code;
437
+ connectedCallback(): void;
438
+ protected willUpdate(changed: Map<string, unknown>): void;
439
+ protected updated(changed: Map<string, unknown>): void;
440
+ /** React to store transitions: MFA pending, redirect results, sign in. */
441
+ private syncFromStore;
442
+ /** Navigate between screens and reset transient state. */
443
+ go(step: Step): void;
444
+ private run;
445
+ private onSignIn;
446
+ private onSignUp;
447
+ private onGuest;
448
+ private onOAuth;
449
+ private onForgot;
450
+ private onReset;
451
+ private onMagicUrl;
452
+ private onEmailOtp;
453
+ private onPhoneOtp;
454
+ private onVerifyCode;
455
+ private onChooseFactor;
456
+ private onVerifyFactor;
457
+ private onCancelMfa;
458
+ private onSignOut;
459
+ private bind;
460
+ protected render(): TemplateResult<1>;
461
+ private renderHeader;
462
+ private renderError;
463
+ private submitButton;
464
+ private passwordField;
465
+ private emailField;
466
+ private codeField;
467
+ private legal;
468
+ private backLink;
469
+ private renderStep;
470
+ private renderSignedIn;
471
+ private renderProviders;
472
+ private renderSignIn;
473
+ private renderSignUp;
474
+ private renderForgot;
475
+ private renderReset;
476
+ private phraseBox;
477
+ private renderMagicUrl;
478
+ private renderCodeEntry;
479
+ private renderEmailOtp;
480
+ private renderPhone;
481
+ private renderMfa;
482
+ }
483
+
484
+ export declare interface AuthUIState {
485
+ status: AuthUIStatus;
486
+ user: Models.User<Models.Preferences> | null;
487
+ /** Factors available to complete MFA when status is "mfa-required". */
488
+ mfaFactors: Models.MfaFactors | null;
489
+ pending: AuthUIPendingAction | null;
490
+ configured: boolean;
491
+ }
492
+
493
+ export declare type AuthUIStatus = "loading" | "signed-out" | "signed-in" | "mfa-required";
494
+
495
+ export declare interface AuthUIStrings {
496
+ signIn: string;
497
+ signUp: string;
498
+ signOut: string;
499
+ continueAsGuest: string;
500
+ email: string;
501
+ password: string;
502
+ newPassword: string;
503
+ confirmPassword: string;
504
+ name: string;
505
+ phone: string;
506
+ code: string;
507
+ forgotPassword: string;
508
+ noAccount: string;
509
+ haveAccount: string;
510
+ or: string;
511
+ continueWith: string;
512
+ continueWithEmail: string;
513
+ sendEmailCode: string;
514
+ continueWithPhone: string;
515
+ sendMagicLink: string;
516
+ sendCode: string;
517
+ verifyCode: string;
518
+ magicLinkSent: string;
519
+ codeSent: string;
520
+ securityPhrase: string;
521
+ securityPhraseHint: string;
522
+ back: string;
523
+ cancel: string;
524
+ save: string;
525
+ update: string;
526
+ remove: string;
527
+ close: string;
528
+ resetPassword: string;
529
+ resetLinkSent: string;
530
+ passwordUpdated: string;
531
+ sendResetLink: string;
532
+ agreeTo: string;
533
+ terms: string;
534
+ privacy: string;
535
+ and: string;
536
+ welcomeBack: string;
537
+ createAccount: string;
538
+ signInTitle: string;
539
+ signUpTitle: string;
540
+ mfaTitle: string;
541
+ mfaDescription: string;
542
+ mfaUseAuthenticator: string;
543
+ mfaUseEmail: string;
544
+ mfaUsePhone: string;
545
+ mfaUseRecoveryCode: string;
546
+ recoveryCode: string;
547
+ account: string;
548
+ profile: string;
549
+ security: string;
550
+ sessions: string;
551
+ connections: string;
552
+ activity: string;
553
+ dangerZone: string;
554
+ verified: string;
555
+ unverified: string;
556
+ verifyEmail: string;
557
+ verificationSent: string;
558
+ emailVerified: string;
559
+ changePassword: string;
560
+ currentPassword: string;
561
+ twoFactor: string;
562
+ twoFactorDescription: string;
563
+ enable: string;
564
+ disable: string;
565
+ authenticatorApp: string;
566
+ authenticatorAdd: string;
567
+ authenticatorScan: string;
568
+ authenticatorManual: string;
569
+ authenticatorVerify: string;
570
+ recoveryCodes: string;
571
+ recoveryCodesDescription: string;
572
+ generateRecoveryCodes: string;
573
+ regenerateRecoveryCodes: string;
574
+ recoveryCodesWarning: string;
575
+ currentSession: string;
576
+ signOutSession: string;
577
+ signOutAllSessions: string;
578
+ signOutAllSessionsDescription: string;
579
+ noConnections: string;
580
+ disconnect: string;
581
+ noActivity: string;
582
+ deleteAccount: string;
583
+ deleteAccountDescription: string;
584
+ deleteAccountConfirm: string;
585
+ loading: string;
586
+ copied: string;
587
+ copy: string;
588
+ done: string;
589
+ errorGeneric: string;
590
+ errorInvalidCredentials: string;
591
+ errorUserExists: string;
592
+ errorUserBlocked: string;
593
+ errorRateLimit: string;
594
+ errorInvalidToken: string;
595
+ errorInvalidCode: string;
596
+ errorPasswordMismatch: string;
597
+ errorPasswordRecentlyUsed: string;
598
+ errorPasswordPersonalData: string;
599
+ errorPasswordWeak: string;
600
+ errorPasswordPwned: string;
601
+ errorChallengeRequired: string;
602
+ errorSessionExists: string;
603
+ errorOAuth: string;
604
+ errorNetwork: string;
605
+ errorMethodDisabled: string;
606
+ errorNotConfigured: string;
607
+ passwordHint: string;
608
+ signedInAs: string;
609
+ manageAccount: string;
610
+ continue: string;
611
+ provider: string;
612
+ lastActive: string;
613
+ guestAccount: string;
614
+ guestAccountDescription: string;
615
+ }
616
+
617
+ export declare type AuthUITheme = "light" | "dark" | "auto";
618
+
619
+ /**
620
+ * Avatar with a menu: shows a sign-in button while signed out, and the user's
621
+ * avatar with "Manage account" and "Sign out" while signed in.
622
+ */
623
+ export declare class AuthUIUserButton extends AuthUIElement {
624
+ static styles: CSSResult[];
625
+ /** Avatar image URL; falls back to initials. */
626
+ src: string;
627
+ private menuOpen;
628
+ connectedCallback(): void;
629
+ disconnectedCallback(): void;
630
+ private onDocumentClick;
631
+ private onKeydown;
632
+ protected render(): TemplateResult<1>;
633
+ }
634
+
635
+ /** Screens the widget can show. */
636
+ export declare type AuthUIView = "sign-in" | "sign-up" | "forgot-password" | "reset-password" | "magic-url" | "email-otp" | "phone" | "mfa" | "account";
637
+
638
+ declare function close_2(): void;
639
+ export { close_2 as close }
640
+
641
+ export declare function closeModal(): void;
642
+
643
+ declare abstract class ConditionalElement extends LitElement {
644
+ protected abstract shouldShow(status: AuthUIStatus): boolean;
645
+ private show;
646
+ private unsubscribe;
647
+ connectedCallback(): void;
648
+ disconnectedCallback(): void;
649
+ private evaluate;
650
+ protected render(): TemplateResult<1> | typeof nothing;
651
+ }
652
+
653
+ export declare const defaultStrings: AuthUIStrings;
654
+
655
+ /**
656
+ * Pick a friendly message for an error, falling back to Appwrite's own text.
657
+ * Pass `context: "code"` when the user typed a one-time code so an invalid
658
+ * token reads as "wrong code" instead of "expired link".
659
+ */
660
+ export declare function describeError(err: unknown, s: AuthUIStrings, context?: "link" | "code"): string;
661
+
662
+ /** Appwrite error `type` strings the UI reacts to. */
663
+ export declare const ErrorTypes: {
664
+ readonly moreFactorsRequired: "user_more_factors_required";
665
+ readonly invalidCredentials: "user_invalid_credentials";
666
+ readonly userAlreadyExists: "user_already_exists";
667
+ readonly emailAlreadyExists: "user_email_already_exists";
668
+ readonly phoneAlreadyExists: "user_phone_already_exists";
669
+ readonly userBlocked: "user_blocked";
670
+ readonly rateLimit: "general_rate_limit_exceeded";
671
+ readonly invalidToken: "user_invalid_token";
672
+ readonly invalidCode: "user_invalid_code";
673
+ readonly passwordMismatch: "user_password_mismatch";
674
+ readonly passwordRecentlyUsed: "password_recently_used";
675
+ readonly passwordPersonalData: "password_personal_data";
676
+ readonly passwordWeak: "user_password_weak";
677
+ readonly passwordPwned: "password_pwned";
678
+ readonly challengeRequired: "user_challenge_required";
679
+ readonly recoveryCodesExist: "user_recovery_codes_already_exists";
680
+ readonly recoveryCodesNotFound: "user_recovery_codes_not_found";
681
+ readonly authenticatorNotFound: "user_authenticator_not_found";
682
+ readonly routeNotFound: "general_route_not_found";
683
+ readonly emailAlreadyVerified: "user_email_already_verified";
684
+ readonly sessionNotFound: "user_session_not_found";
685
+ readonly wafChallenged: "waf_request_challenged";
686
+ readonly sessionAlreadyExists: "user_session_already_exists";
687
+ readonly oauthUnauthorized: "user_oauth2_unauthorized";
688
+ readonly oauthBadRequest: "user_oauth2_bad_request";
689
+ readonly unauthorized: "general_unauthorized_scope";
690
+ readonly userUnauthorized: "user_unauthorized";
691
+ readonly authMethodUnsupported: "user_auth_method_unsupported";
692
+ readonly countMaxExceeded: "user_count_exceeded";
693
+ readonly targetAlreadyExists: "user_target_already_exists";
694
+ };
695
+
696
+ export declare function getClient(): Client | null;
697
+
698
+ export declare function getState(): AuthUIState;
699
+
700
+ export declare function getUser(): Models.User<Models.Preferences> | null;
701
+
702
+ /** Configure Auth UI. Call once, as early as possible. */
703
+ export declare function init(config: AuthUIConfig): {
704
+ init: typeof init;
705
+ open: typeof open_2;
706
+ close: typeof close_2;
707
+ signOut: typeof signOut;
708
+ getUser: typeof getUser;
709
+ getState: typeof getState;
710
+ getClient: typeof getClient;
711
+ on: typeof on;
712
+ store: AuthStore;
713
+ };
714
+
715
+ declare type Listener<K extends AuthUIEventName> = (detail: AuthUIEventMap[K]) => void;
716
+
717
+ declare type MfaFactor = "totp" | "email" | "phone" | "recoverycode";
718
+
719
+ /** Every OAuth2 provider slug Appwrite understands. */
720
+ export declare type OAuthProviderName = "amazon" | "apple" | "appwrite" | "auth0" | "authentik" | "autodesk" | "bitbucket" | "bitly" | "box" | "cloudflare" | "dailymotion" | "discord" | "disqus" | "dropbox" | "etsy" | "facebook" | "figma" | "fusionauth" | "github" | "gitlab" | "google" | "huggingface" | "kakao" | "keycloak" | "kick" | "linkedin" | "microsoft" | "notion" | "oidc" | "okta" | "paypal" | "paypalSandbox" | "podio" | "resend" | "salesforce" | "slack" | "spotify" | "stripe" | "tiktok" | "tradeshift" | "tradeshiftBox" | "twitch" | "wordpress" | "x" | "yahoo" | "yammer" | "yandex" | "zoho" | "zoom";
721
+
722
+ export declare function on<K extends AuthUIEventName>(event: K, listener: (detail: AuthUIEventMap[K]) => void): () => void;
723
+
724
+ /** Open the modal on a given screen. Creates <authui-modal> if the page has none. */
725
+ declare function open_2(view?: AuthUIView): void;
726
+ export { open_2 as open }
727
+
728
+ /**
729
+ * Open the modal from anywhere. If no <authui-modal> exists yet, one is appended to <body>.
730
+ */
731
+ export declare function openModal(view?: AuthUIView): void;
732
+
733
+ export declare function providerLabel(provider: string): string;
734
+
735
+ export declare function signOut(): Promise<void>;
736
+
737
+ declare type Step = Exclude<AuthUIView, "account">;
738
+
739
+ declare type Tab = "profile" | "security" | "sessions" | "connections" | "activity";
740
+
741
+ export declare function toAuthUIError(err: unknown): AuthUIError;
742
+
743
+ export { }