@getauthui/core 0.1.0 → 0.1.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.
Files changed (51) hide show
  1. package/README.md +15 -15
  2. package/dist/{authui-user-button-3yi-kvES.js → authui-user-button-BRfrh3si.js} +901 -485
  3. package/dist/authui.cdn.js +227 -215
  4. package/dist/authui.cdn.mjs +6721 -3340
  5. package/dist/authui.js +46 -34
  6. package/dist/components/authui-account.d.ts +102 -0
  7. package/dist/components/authui-account.d.ts.map +1 -0
  8. package/dist/components/authui-button.d.ts +21 -0
  9. package/dist/components/authui-button.d.ts.map +1 -0
  10. package/dist/components/authui-config.d.ts +40 -0
  11. package/dist/components/authui-config.d.ts.map +1 -0
  12. package/dist/components/authui-modal.d.ts +38 -0
  13. package/dist/components/authui-modal.d.ts.map +1 -0
  14. package/dist/components/authui-show.d.ts +33 -0
  15. package/dist/components/authui-show.d.ts.map +1 -0
  16. package/dist/components/authui-sign-in.d.ts +83 -0
  17. package/dist/components/authui-sign-in.d.ts.map +1 -0
  18. package/dist/components/authui-user-button.d.ts +22 -0
  19. package/dist/components/authui-user-button.d.ts.map +1 -0
  20. package/dist/components/element.d.ts +24 -0
  21. package/dist/components/element.d.ts.map +1 -0
  22. package/dist/components/sign-in.styles.d.ts +2 -0
  23. package/dist/components/sign-in.styles.d.ts.map +1 -0
  24. package/dist/errors.d.ts +48 -0
  25. package/dist/errors.d.ts.map +1 -0
  26. package/dist/i18n.d.ts +8 -0
  27. package/dist/i18n.d.ts.map +1 -0
  28. package/dist/icons.d.ts +38 -0
  29. package/dist/icons.d.ts.map +1 -0
  30. package/dist/index.d.ts +62 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/modal-controller.d.ts +7 -0
  33. package/dist/modal-controller.d.ts.map +1 -0
  34. package/dist/preview.d.ts +107 -0
  35. package/dist/preview.d.ts.map +1 -0
  36. package/dist/react/index.d.ts +53 -0
  37. package/dist/react/index.d.ts.map +1 -0
  38. package/dist/react.js +21 -25
  39. package/dist/store.d.ts +105 -0
  40. package/dist/store.d.ts.map +1 -0
  41. package/dist/styles/base.d.ts +7 -0
  42. package/dist/styles/base.d.ts.map +1 -0
  43. package/dist/styles/tokens.d.ts +7 -0
  44. package/dist/styles/tokens.d.ts.map +1 -0
  45. package/dist/theme.d.ts +21 -0
  46. package/dist/theme.d.ts.map +1 -0
  47. package/dist/types.d.ts +233 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/package.json +4 -4
  50. package/dist/authui.d.ts +0 -743
  51. package/dist/react.d.ts +0 -395
@@ -0,0 +1,62 @@
1
+ import { AuthUIConfig, AuthUIEventMap, AuthUIEventName, AuthUIView } from './types.js';
2
+ export { AuthUIElement } from './components/element.js';
3
+ export { AuthUIConfigElement } from './components/authui-config.js';
4
+ export { AuthUIShow } from './components/authui-show.js';
5
+ export { AuthUISignIn } from './components/authui-sign-in.js';
6
+ export { AuthUIAccount } from './components/authui-account.js';
7
+ export { AuthUIModal } from './components/authui-modal.js';
8
+ export { AuthUIButton } from './components/authui-button.js';
9
+ export { AuthUIUserButton } from './components/authui-user-button.js';
10
+ export { authStore, AuthStore } from './store.js';
11
+ export { openModal, closeModal } from './modal-controller.js';
12
+ export { describeError, ErrorTypes, toAuthUIError } from './errors.js';
13
+ export { PreviewAccount } from './preview.js';
14
+ export { defaultStrings, providerLabel } from './i18n.js';
15
+ /**
16
+ * The Appwrite Web SDK Auth UI is built on, re-exported so script-tag users can reach
17
+ * Storage, Databases, Query, ID, Permission and Role without loading the SDK twice:
18
+ * `const { Storage, ID } = appwrite;`
19
+ */
20
+ export * as appwrite from 'appwrite';
21
+ export * from './types.js';
22
+ /** Configure Auth UI. Call once, as early as possible. */
23
+ export declare function init(config: AuthUIConfig): {
24
+ init: typeof init;
25
+ open: typeof open;
26
+ close: typeof close;
27
+ signOut: typeof signOut;
28
+ getUser: typeof getUser;
29
+ getState: typeof getState;
30
+ getClient: typeof getClient;
31
+ getAccount: typeof getAccount;
32
+ on: typeof on;
33
+ previewSignIn: typeof previewSignIn;
34
+ store: import('./store.js').AuthStore;
35
+ };
36
+ /** Open the modal on a given screen. Creates <authui-modal> if the page has none. */
37
+ export declare function open(view?: AuthUIView): void;
38
+ export declare function close(): void;
39
+ export declare function signOut(): Promise<void>;
40
+ export declare function getUser(): import("appwrite").Models.User<import("appwrite").Models.Preferences> | null;
41
+ export declare function getState(): import('./types.js').AuthUIState;
42
+ export declare function getClient(): import('appwrite').Client | null;
43
+ /** The Appwrite Account service Auth UI uses. Handy for `getPrefs()` and `updatePrefs()`. */
44
+ export declare function getAccount(): import('appwrite').Account | null;
45
+ /** Preview mode only: sign the sample user in without a form. */
46
+ export declare function previewSignIn(): Promise<void>;
47
+ export declare function on<K extends AuthUIEventName>(event: K, listener: (detail: AuthUIEventMap[K]) => void): () => void;
48
+ /** Convenience namespace: `AuthUI.init({...}); AuthUI.open();` */
49
+ export declare const AuthUI: {
50
+ init: typeof init;
51
+ open: typeof open;
52
+ close: typeof close;
53
+ signOut: typeof signOut;
54
+ getUser: typeof getUser;
55
+ getState: typeof getState;
56
+ getClient: typeof getClient;
57
+ getAccount: typeof getAccount;
58
+ on: typeof on;
59
+ previewSignIn: typeof previewSignIn;
60
+ store: import('./store.js').AuthStore;
61
+ };
62
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAA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
1
+ import { AuthUIView } from './types.js';
2
+ /**
3
+ * Open the modal from anywhere. If no <authui-modal> exists yet, one is appended to <body>.
4
+ */
5
+ export declare function openModal(view?: AuthUIView): void;
6
+ export declare function closeModal(): void;
7
+ //# sourceMappingURL=modal-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal-controller.d.ts","sourceRoot":"","sources":["../src/modal-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,IAAI,CASjD;AAED,wBAAgB,UAAU,IAAI,IAAI,CAGjC"}
@@ -0,0 +1,107 @@
1
+ import { Models } from 'appwrite';
2
+ interface PreviewUserSeed {
3
+ name: string;
4
+ email: string;
5
+ phone: string;
6
+ }
7
+ export declare class PreviewAccount {
8
+ private seed;
9
+ user: (Models.User<Models.Preferences> & Record<string, unknown>) | null;
10
+ /** True after a primary sign in while the account has MFA and a usable factor. */
11
+ mfaPending: boolean;
12
+ /** Account-level setting; survives sign out like it would on the server. */
13
+ mfaEnabled: boolean;
14
+ totpEnrolled: boolean;
15
+ recoveryCodes: string[];
16
+ /** Time of the last completed challenge; protected actions need one within 30 minutes. */
17
+ lastChallenge: number;
18
+ sessions: Models.Session[];
19
+ identities: Models.Identity[];
20
+ logs: Models.Log[];
21
+ /** Tokens waiting to be redeemed by userId. */
22
+ private tokens;
23
+ private pendingAuthenticator;
24
+ constructor(seed?: PreviewUserSeed);
25
+ private makeUser;
26
+ private seedActivity;
27
+ private requireUser;
28
+ private requireRecentChallenge;
29
+ private afterPrimarySignIn;
30
+ private delay;
31
+ /** Sign the preview user in directly (used by the playground). */
32
+ signInDirectly(): void;
33
+ get(): Promise<Models.User<Models.Preferences> & Record<string, unknown>>;
34
+ create(_userId: string, email: string, _password: string, name?: string): Promise<Models.User<Models.Preferences> & Record<string, unknown>>;
35
+ createEmailPasswordSession(email: string): Promise<Models.Session>;
36
+ createAnonymousSession(): Promise<Models.Session>;
37
+ createOAuth2Token(provider: string): Promise<void>;
38
+ createMagicURLToken(userId: string, email: string): Promise<{
39
+ $id: string;
40
+ $createdAt: string;
41
+ userId: string;
42
+ secret: string;
43
+ expire: string;
44
+ phrase: string;
45
+ }>;
46
+ createEmailToken(userId: string, email: string): Promise<{
47
+ $id: string;
48
+ $createdAt: string;
49
+ userId: string;
50
+ secret: string;
51
+ expire: string;
52
+ phrase: string;
53
+ }>;
54
+ createPhoneToken(userId: string, phone: string): Promise<{
55
+ $id: string;
56
+ $createdAt: string;
57
+ userId: string;
58
+ secret: string;
59
+ expire: string;
60
+ phrase: string;
61
+ }>;
62
+ createSession(userId: string): Promise<Models.Session>;
63
+ createRecovery(): Promise<{}>;
64
+ updateRecovery(): Promise<{}>;
65
+ createEmailVerification(): Promise<{}>;
66
+ updateEmailVerification(): Promise<{}>;
67
+ createPhoneVerification(): Promise<{}>;
68
+ updatePhoneVerification(): Promise<{}>;
69
+ getPrefs(): Promise<Models.Preferences>;
70
+ updatePrefs(prefs: object): Promise<Models.User<Models.Preferences> & Record<string, unknown>>;
71
+ updateName(name: string): Promise<Models.User<Models.Preferences> & Record<string, unknown>>;
72
+ updateEmail(email: string): Promise<Models.User<Models.Preferences> & Record<string, unknown>>;
73
+ updatePhone(phone: string): Promise<Models.User<Models.Preferences> & Record<string, unknown>>;
74
+ updatePassword(): Promise<Models.User<Models.Preferences> & Record<string, unknown>>;
75
+ updateStatus(): Promise<{}>;
76
+ listSessions(): Promise<{
77
+ total: number;
78
+ sessions: Models.Session[];
79
+ }>;
80
+ deleteSession(sessionId?: string): Promise<{}>;
81
+ deleteSessions(): Promise<{}>;
82
+ listIdentities(): Promise<{
83
+ total: number;
84
+ identities: Models.Identity[];
85
+ }>;
86
+ deleteIdentity(identityId: string): Promise<{}>;
87
+ listLogs(): Promise<{
88
+ total: number;
89
+ logs: Models.Log[];
90
+ }>;
91
+ listMFAFactors(): Promise<Models.MfaFactors>;
92
+ createMFAChallenge(): Promise<Models.MfaChallenge>;
93
+ updateMFAChallenge(): Promise<Models.Session>;
94
+ updateMFA(mfa: boolean): Promise<Models.User<Models.Preferences> & Record<string, unknown>>;
95
+ createMFAAuthenticator(): Promise<Models.MfaType>;
96
+ updateMFAAuthenticator(): Promise<Models.User<Models.Preferences> & Record<string, unknown>>;
97
+ deleteMFAAuthenticator(): Promise<{}>;
98
+ createMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes>;
99
+ getMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes>;
100
+ updateMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes>;
101
+ /** Forget everything, as a sign out would. */
102
+ reset(): void;
103
+ }
104
+ /** A deterministic, QR-looking placeholder rendered while previewing authenticator setup. */
105
+ export declare function previewQrDataUrl(seed: string): string;
106
+ export {};
107
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAkCvC,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAQD,qBAAa,cAAc;IAiBb,OAAO,CAAC,IAAI;IAhBxB,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAQ;IAChF,kFAAkF;IAClF,UAAU,UAAS;IACnB,4EAA4E;IAC5E,UAAU,UAAS;IACnB,YAAY,UAAS;IACrB,aAAa,EAAE,MAAM,EAAE,CAAM;IAC7B,0FAA0F;IAC1F,aAAa,SAAK;IAClB,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,CAAM;IAChC,UAAU,EAA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AAM;IAOjC,QAAQ;;;;IASR,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;IAU5C,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;IAIlD,kBAAkB;IAQlB,SAAS,CAAC,GAAG,EAAE,OAAO;IAStB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;IAWjD,sBAAsB;IAStB,sBAAsB;IAQtB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAU1D,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAOvD,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAQhE,8CAA8C;IAC9C,KAAK,IAAI,IAAI;CAQd;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBrD"}
@@ -0,0 +1,53 @@
1
+ import { ReactElement, ReactNode } from 'react';
2
+ import { openModal, closeModal } from '../modal-controller.js';
3
+ import { AuthUIConfig, AuthUIView } from '../types.js';
4
+ /** Subscribe to Auth UI state and get the imperative helpers. */
5
+ export declare function useAuthUI(): {
6
+ open: typeof openModal;
7
+ close: typeof closeModal;
8
+ signOut: () => Promise<void>;
9
+ store: import('../store.js').AuthStore;
10
+ status: import('../types.js').AuthUIStatus;
11
+ user: import("appwrite").Models.User<import("appwrite").Models.Preferences> | null;
12
+ mfaFactors: import("appwrite").Models.MfaFactors | null;
13
+ pending: import('../types.js').AuthUIPendingAction | null;
14
+ configured: boolean;
15
+ };
16
+ /** Configures Auth UI once and renders children. Put it near the root of your app. */
17
+ export declare function AuthUIProvider({ config, children, }: {
18
+ config: AuthUIConfig;
19
+ children?: ReactNode;
20
+ }): ReactElement;
21
+ export declare function AuthUIModal(props: {
22
+ view?: AuthUIView;
23
+ open?: boolean;
24
+ closeOnSuccess?: boolean;
25
+ }): ReactElement;
26
+ export declare function AuthUIButton(props: {
27
+ view?: AuthUIView;
28
+ variant?: "primary" | "brand" | "outline" | "secondary" | "ghost" | "link";
29
+ size?: "sm" | "md" | "lg";
30
+ children?: ReactNode;
31
+ }): ReactElement;
32
+ export declare function AuthUISignIn(props: {
33
+ view?: Exclude<AuthUIView, "account">;
34
+ onSuccess?: () => void;
35
+ }): ReactElement;
36
+ export declare function AuthUIAccount(props: {
37
+ tab?: "profile" | "security" | "sessions" | "connections" | "activity";
38
+ }): ReactElement;
39
+ export declare function AuthUIUserButton(props: {
40
+ src?: string;
41
+ children?: ReactNode;
42
+ }): ReactElement;
43
+ /**
44
+ * Renders children only while the auth status matches.
45
+ * `when` and `unless` accept a status or a comma separated list:
46
+ * `signed-in`, `signed-out`, `mfa-required`, `loading`.
47
+ */
48
+ export declare function Show(props: {
49
+ when?: string;
50
+ unless?: string;
51
+ children?: ReactNode;
52
+ }): ReactElement;
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAe,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzE,OAAO,gCAAgC,CAAC;AACxC,OAAO,8BAA8B,CAAC;AACtC,OAAO,iCAAiC,CAAC;AACzC,OAAO,iCAAiC,CAAC;AACzC,OAAO,+BAA+B,CAAC;AACvC,OAAO,gCAAgC,CAAC;AACxC,OAAO,qCAAqC,CAAC;AAE7C,iEAAiE;AACjE,wBAAgB,SAAS;;;;;;;;;;EAUxB;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,YAAY,CAAC;IACrB,QAA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"react";
2
- import { a as u, c as a, o as l } from "./authui-user-button-3yi-kvES.js";
1
+ import { createElement as n, useEffect as i, Fragment as r, useState as s } from "react";
2
+ import { a as u, c as a, o as h } from "./authui-user-button-BRfrh3si.js";
3
3
  function v() {
4
- const [t, e] = r(() => u.getState());
4
+ const [t, e] = s(() => u.getState());
5
5
  return i(() => u.on("change", e), []), {
6
6
  ...t,
7
- open: l,
7
+ open: h,
8
8
  close: a,
9
9
  signOut: () => u.signOut(),
10
10
  store: u
11
11
  };
12
12
  }
13
- function g({
13
+ function S({
14
14
  config: t,
15
15
  children: e
16
16
  }) {
17
17
  return i(() => {
18
18
  u.configure(t);
19
- }, [t.endpoint, t.project]), n(s, null, e);
19
+ }, [t.endpoint, t.project]), n(r, null, e);
20
20
  }
21
- function S(t) {
21
+ function w(t) {
22
22
  return n("authui-modal", {
23
23
  view: t.view,
24
24
  open: t.open || void 0,
@@ -32,37 +32,33 @@ function I(t) {
32
32
  t.children
33
33
  );
34
34
  }
35
- function m(t) {
36
- return n(h, t);
35
+ function g(t) {
36
+ return n(l, t);
37
37
  }
38
- function h(t) {
39
- const [e, o] = r(null);
38
+ function l(t) {
39
+ const [e, o] = s(null);
40
40
  return i(() => {
41
41
  if (!e || !t.onSuccess) return;
42
42
  const c = () => t.onSuccess?.();
43
43
  return e.addEventListener("authui-success", c), () => e.removeEventListener("authui-success", c);
44
44
  }, [e, t.onSuccess]), n("authui-sign-in", { ref: o, view: t.view });
45
45
  }
46
- function A(t) {
46
+ function m(t) {
47
47
  return n("authui-account", { tab: t.tab });
48
48
  }
49
- function U(t) {
49
+ function A(t) {
50
50
  return n("authui-user-button", { src: t.src }, t.children);
51
51
  }
52
- function w({ children: t }) {
53
- return n("authui-signed-in", null, t);
54
- }
55
- function E({ children: t }) {
56
- return n("authui-signed-out", null, t);
52
+ function U(t) {
53
+ return n("authui-show", { when: t.when, unless: t.unless }, t.children);
57
54
  }
58
55
  export {
59
- A as AuthUIAccount,
56
+ m as AuthUIAccount,
60
57
  I as AuthUIButton,
61
- S as AuthUIModal,
62
- g as AuthUIProvider,
63
- m as AuthUISignIn,
64
- U as AuthUIUserButton,
65
- w as SignedIn,
66
- E as SignedOut,
58
+ w as AuthUIModal,
59
+ S as AuthUIProvider,
60
+ g as AuthUISignIn,
61
+ A as AuthUIUserButton,
62
+ U as Show,
67
63
  v as useAuthUI
68
64
  };
@@ -0,0 +1,105 @@
1
+ import { Account, Client, Models } from 'appwrite';
2
+ import { AuthUIConfig, AuthUIEventMap, AuthUIEventName, AuthUIPendingAction, AuthUIState, AuthUIStrings, OAuthProviderName } from './types.js';
3
+ export type MfaFactor = "totp" | "email" | "phone" | "recoverycode";
4
+ type Listener<K extends AuthUIEventName> = (detail: AuthUIEventMap[K]) => void;
5
+ /**
6
+ * Single source of truth for the widget. Wraps the Appwrite Account service,
7
+ * tracks the signed-in user and broadcasts changes on `window` as `authui:change`.
8
+ */
9
+ export declare class AuthStore {
10
+ private client;
11
+ private account;
12
+ private config;
13
+ private state;
14
+ private listeners;
15
+ private refreshPromise;
16
+ /** Configure the Appwrite client. Safe to call more than once; the last call wins. */
17
+ configure(config: AuthUIConfig): void;
18
+ private preview;
19
+ get isConfigured(): boolean;
20
+ /** True when running against the in-memory preview account. */
21
+ get isPreview(): boolean;
22
+ /** Preview only: sign the sample user in without any form. */
23
+ previewSignIn(): Promise<void>;
24
+ getConfig(): AuthUIConfig | null;
25
+ /** The configured Appwrite client, for apps that want to reuse it. */
26
+ getClient(): Client | null;
27
+ /**
28
+ * The Account service Auth UI talks to. Reuse it for prefs, JWTs or anything else
29
+ * on the signed-in account. In preview mode this is the in-memory stand-in.
30
+ */
31
+ getAccount(): Account | null;
32
+ getStrings(): AuthUIStrings;
33
+ getState(): AuthUIState;
34
+ get user(): Models.User<Models.Preferences> | null;
35
+ on<K extends AuthUIEventName>(event: K, listener: Listener<K>): () => void;
36
+ private emit;
37
+ private setState;
38
+ private fail;
39
+ private acct;
40
+ /** Re-fetch the current user and derive status. */
41
+ refresh(): Promise<void>;
42
+ private afterSignIn;
43
+ signInWithEmailPassword(email: string, password: string): Promise<void>;
44
+ signUp(email: string, password: string, name?: string): Promise<void>;
45
+ signInAnonymously(): Promise<void>;
46
+ /**
47
+ * Redirects the browser to the provider; the returned promise only resolves in
48
+ * preview mode, where the sign in completes in place.
49
+ */
50
+ signInWithOAuth(provider: OAuthProviderName): Promise<void>;
51
+ sendMagicUrl(email: string): Promise<Models.Token>;
52
+ sendEmailOtp(email: string): Promise<Models.Token>;
53
+ sendPhoneOtp(phone: string): Promise<Models.Token>;
54
+ /** Redeem any token secret (email OTP, SMS OTP, magic URL, OAuth token). */
55
+ signInWithToken(userId: string, secret: string): Promise<void>;
56
+ createMfaChallenge(factor: MfaFactor): Promise<Models.MfaChallenge>;
57
+ /** Verify a challenge. Completes a pending sign in, or acts as a step-up for protected actions. */
58
+ completeMfaChallenge(challengeId: string, otp: string, opts?: {
59
+ signIn?: boolean;
60
+ }): Promise<void>;
61
+ listMfaFactors(): Promise<Models.MfaFactors>;
62
+ setMfaEnabled(enabled: boolean): Promise<void>;
63
+ addAuthenticator(): Promise<Models.MfaType>;
64
+ verifyAuthenticator(otp: string): Promise<void>;
65
+ /** Requires a recent MFA challenge (server rejects with user_challenge_required otherwise). */
66
+ removeAuthenticator(): Promise<void>;
67
+ createRecoveryCodes(): Promise<string[]>;
68
+ /** Requires a recent MFA challenge. */
69
+ regenerateRecoveryCodes(): Promise<string[]>;
70
+ /** Requires a recent MFA challenge. */
71
+ getRecoveryCodes(): Promise<string[]>;
72
+ sendPasswordRecovery(email: string): Promise<void>;
73
+ completePasswordRecovery(userId: string, secret: string, password: string): Promise<void>;
74
+ signOut(sessionId?: string): Promise<void>;
75
+ signOutEverywhere(): Promise<void>;
76
+ listSessions(): Promise<Models.Session[]>;
77
+ listIdentities(): Promise<Models.Identity[]>;
78
+ deleteIdentity(identityId: string): Promise<void>;
79
+ listLogs(): Promise<Models.Log[]>;
80
+ updateName(name: string): Promise<void>;
81
+ updateEmail(email: string, password: string): Promise<void>;
82
+ updatePhone(phone: string, password: string): Promise<void>;
83
+ updatePassword(password: string, oldPassword?: string): Promise<void>;
84
+ /** Turn an anonymous session into a full account. */
85
+ convertGuest(email: string, password: string, name?: string): Promise<void>;
86
+ sendEmailVerification(): Promise<void>;
87
+ sendPhoneVerification(): Promise<void>;
88
+ confirmPhoneVerification(otp: string): Promise<void>;
89
+ /** Blocks the account and ends the session. Appwrite keeps the record so an admin can restore it. */
90
+ deleteAccount(): Promise<void>;
91
+ /** Build the URL Appwrite should send the user back to for a given flow. */
92
+ redirectUrl(action: string): string;
93
+ setPending(pending: AuthUIPendingAction | null): void;
94
+ /**
95
+ * Finish a flow that arrived through the URL. Called automatically by `configure()`.
96
+ * Returns true when a redirect was handled.
97
+ */
98
+ handleRedirect(): Promise<boolean>;
99
+ private cleanUrl;
100
+ /** Test helper. */
101
+ reset(): void;
102
+ }
103
+ export declare const authStore: AuthStore;
104
+ export {};
105
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAM,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAkB5D,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,CAAC;AAIpE,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAOpB,KAAK,QAAQ,CAAC,CAAC,SAAS,eAAe,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAU/E;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,MAAM,CAA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AO,EAAE,mBAAmB,GAAG,IAAI,GAAG,IAAI;IAIrD;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAgDxC,OAAO,CAAC,QAAQ;IAMhB,mBAAmB;IACnB,KAAK,IAAI,IAAI;CAQd;AAED,eAAO,MAAM,SAAS,WAAkB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shared component styles. Class names mirror the shadcn primitives used in the
3
+ * console (button variants, input, label, alert, badge, tabs, separator) so the
4
+ * widget reads as part of the same system.
5
+ */
6
+ export declare const base: import('lit').CSSResult;
7
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/styles/base.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,IAAI,yBAsuBhB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Design tokens ported from the Appwrite Console v4 design system (shadcn "new-york", zinc base).
3
+ * Every token is a CSS custom property on :host so developers can override any of them
4
+ * from the page, e.g. `authui-modal { --authui-primary: #fd366e; }`.
5
+ */
6
+ export declare const tokens: import('lit').CSSResult;
7
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/styles/tokens.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,MAAM,yBA8ElB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { AuthUITheme } from './types.js';
2
+ type ThemeListener = (dark: boolean) => void;
3
+ /**
4
+ * Resolves "auto" theme against the host page: an explicit `dark` or `light` class on
5
+ * <html> wins (next-themes / shadcn convention, and what the Appwrite Console uses),
6
+ * otherwise prefers-color-scheme decides. One observer is shared by all components.
7
+ */
8
+ declare class ThemeWatcher {
9
+ private listeners;
10
+ private observer;
11
+ private media;
12
+ isDark(theme?: AuthUITheme): boolean;
13
+ subscribe(listener: ThemeListener): () => void;
14
+ private notify;
15
+ private start;
16
+ private stop;
17
+ }
18
+ export declare const themeWatcher: ThemeWatcher;
19
+ export declare const radiusScale: Record<string, string>;
20
+ export {};
21
+ //# sourceMappingURL=theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;AAE7C;;;;GAIG;AACH,cAAM,YAAY;IAChB,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,QAAQ,CAAiC;IACjD,OAAO,CAAC,KAAK,CAA+B;IAE5C,MAAM,CAAC,KAAK,GAAE,WAAoB,GAAG,OAAO;IAc5C,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,IAAI;IAS9C,OAAO,CAAC,MAAM,CAGZ;IAEF,OAAO,CAAC,KAAK;IAab,OAAO,CAAC,IAAI;CAMb;AAED,eAAO,MAAM,YAAY,cAAqB,CAAC;AAE/C,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAO9C,CAAC"}