@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
package/dist/react.d.ts DELETED
@@ -1,395 +0,0 @@
1
- import { Client } from 'appwrite';
2
- import { Models } from 'appwrite';
3
- import { ReactElement } from 'react';
4
- import { ReactNode } from 'react';
5
-
6
- /**
7
- * Single source of truth for the widget. Wraps the Appwrite Account service,
8
- * tracks the signed-in user and broadcasts changes on `window` as `authui:change`.
9
- */
10
- declare class AuthStore {
11
- private client;
12
- private account;
13
- private config;
14
- private state;
15
- private listeners;
16
- private refreshPromise;
17
- /** Configure the Appwrite client. Safe to call more than once; the last call wins. */
18
- configure(config: AuthUIConfig): void;
19
- get isConfigured(): boolean;
20
- getConfig(): AuthUIConfig | null;
21
- /** The configured Appwrite client, for apps that want to reuse it. */
22
- getClient(): Client | null;
23
- getStrings(): AuthUIStrings;
24
- getState(): AuthUIState;
25
- get user(): Models.User<Models.Preferences> | null;
26
- on<K extends AuthUIEventName>(event: K, listener: Listener<K>): () => void;
27
- private emit;
28
- private setState;
29
- private fail;
30
- private acct;
31
- /** Re-fetch the current user and derive status. */
32
- refresh(): Promise<void>;
33
- private afterSignIn;
34
- signInWithEmailPassword(email: string, password: string): Promise<void>;
35
- signUp(email: string, password: string, name?: string): Promise<void>;
36
- signInAnonymously(): Promise<void>;
37
- /** Redirects the browser to the provider. Never resolves in a browser. */
38
- signInWithOAuth(provider: OAuthProviderName): void;
39
- sendMagicUrl(email: string): Promise<Models.Token>;
40
- sendEmailOtp(email: string): Promise<Models.Token>;
41
- sendPhoneOtp(phone: string): Promise<Models.Token>;
42
- /** Redeem any token secret (email OTP, SMS OTP, magic URL, OAuth token). */
43
- signInWithToken(userId: string, secret: string): Promise<void>;
44
- createMfaChallenge(factor: MfaFactor): Promise<Models.MfaChallenge>;
45
- /** Verify a challenge. Completes a pending sign in, or acts as a step-up for protected actions. */
46
- completeMfaChallenge(challengeId: string, otp: string, opts?: {
47
- signIn?: boolean;
48
- }): Promise<void>;
49
- listMfaFactors(): Promise<Models.MfaFactors>;
50
- setMfaEnabled(enabled: boolean): Promise<void>;
51
- addAuthenticator(): Promise<Models.MfaType>;
52
- verifyAuthenticator(otp: string): Promise<void>;
53
- /** Requires a recent MFA challenge (server rejects with user_challenge_required otherwise). */
54
- removeAuthenticator(): Promise<void>;
55
- createRecoveryCodes(): Promise<string[]>;
56
- /** Requires a recent MFA challenge. */
57
- regenerateRecoveryCodes(): Promise<string[]>;
58
- /** Requires a recent MFA challenge. */
59
- getRecoveryCodes(): Promise<string[]>;
60
- sendPasswordRecovery(email: string): Promise<void>;
61
- completePasswordRecovery(userId: string, secret: string, password: string): Promise<void>;
62
- signOut(sessionId?: string): Promise<void>;
63
- signOutEverywhere(): Promise<void>;
64
- listSessions(): Promise<Models.Session[]>;
65
- listIdentities(): Promise<Models.Identity[]>;
66
- deleteIdentity(identityId: string): Promise<void>;
67
- listLogs(): Promise<Models.Log[]>;
68
- updateName(name: string): Promise<void>;
69
- updateEmail(email: string, password: string): Promise<void>;
70
- updatePhone(phone: string, password: string): Promise<void>;
71
- updatePassword(password: string, oldPassword?: string): Promise<void>;
72
- /** Turn an anonymous session into a full account. */
73
- convertGuest(email: string, password: string, name?: string): Promise<void>;
74
- sendEmailVerification(): Promise<void>;
75
- sendPhoneVerification(): Promise<void>;
76
- confirmPhoneVerification(otp: string): Promise<void>;
77
- /** Blocks the account and ends the session. Appwrite keeps the record so an admin can restore it. */
78
- deleteAccount(): Promise<void>;
79
- /** Build the URL Appwrite should send the user back to for a given flow. */
80
- redirectUrl(action: string): string;
81
- setPending(pending: AuthUIPendingAction | null): void;
82
- /**
83
- * Finish a flow that arrived through the URL. Called automatically by `configure()`.
84
- * Returns true when a redirect was handled.
85
- */
86
- handleRedirect(): Promise<boolean>;
87
- private cleanUrl;
88
- /** Test helper. */
89
- reset(): void;
90
- }
91
-
92
- export declare function AuthUIAccount(props: {
93
- tab?: "profile" | "security" | "sessions" | "connections" | "activity";
94
- }): ReactElement;
95
-
96
- declare interface AuthUIBranding {
97
- /** Product name shown in headings. */
98
- name?: string;
99
- /** Logo URL rendered above the form. */
100
- logo?: string;
101
- /** Color scheme. "auto" follows prefers-color-scheme and an `html.dark` class. Default: "auto". */
102
- theme?: AuthUITheme;
103
- /** Corner radius scale. Default: "md". */
104
- radius?: AuthUIRadius;
105
- /** Any CSS color for primary buttons. Default: near-black / near-white. */
106
- primary?: string;
107
- /** Text color on primary buttons. */
108
- primaryForeground?: string;
109
- }
110
-
111
- export declare function AuthUIButton(props: {
112
- view?: AuthUIView;
113
- variant?: "primary" | "brand" | "outline" | "secondary" | "ghost" | "link";
114
- size?: "sm" | "md" | "lg";
115
- children?: ReactNode;
116
- }): ReactElement;
117
-
118
- declare interface AuthUIConfig {
119
- /** Appwrite API endpoint, e.g. https://cloud.appwrite.io/v1 */
120
- endpoint: string;
121
- /** Appwrite project ID. */
122
- project: string;
123
- /**
124
- * Absolute URL the user returns to after OAuth, magic URL, recovery and verification emails.
125
- * Must be on a hostname registered as a web platform in your Appwrite project.
126
- * Default: the current page without query string or hash.
127
- */
128
- redirectUrl?: string;
129
- /** Where to navigate after a successful sign in. If omitted the page is not changed. */
130
- successUrl?: string;
131
- methods?: AuthUIMethods;
132
- /** Show the "Sign up" option. Default: true. */
133
- signUp?: boolean;
134
- /** Ask for a display name during sign up. Default: true. */
135
- requireName?: boolean;
136
- /** Let users enroll and manage MFA from the account screen. Default: true. */
137
- mfa?: boolean;
138
- /** Request a security phrase for email OTP and magic URL. Default: true. */
139
- securityPhrase?: boolean;
140
- /** Extra OAuth scopes per provider. */
141
- oauthScopes?: Partial<Record<OAuthProviderName, string[]>>;
142
- branding?: AuthUIBranding;
143
- legal?: AuthUILegal;
144
- /** Override any UI string. */
145
- strings?: Partial<AuthUIStrings>;
146
- }
147
-
148
- declare type AuthUIEventMap = {
149
- change: AuthUIState;
150
- "signed-in": Models.User<Models.Preferences>;
151
- "signed-out": undefined;
152
- error: {
153
- message: string;
154
- type: string;
155
- code: number;
156
- };
157
- };
158
-
159
- declare type AuthUIEventName = keyof AuthUIEventMap;
160
-
161
- declare interface AuthUILegal {
162
- termsUrl?: string;
163
- privacyUrl?: string;
164
- }
165
-
166
- declare interface AuthUIMethods {
167
- /** Email + password sign in and sign up. Default: true. */
168
- emailPassword?: boolean;
169
- /** Passwordless link sent by email. Default: false. */
170
- magicUrl?: boolean;
171
- /** Passwordless 6-digit code sent by email. Default: false. */
172
- emailOtp?: boolean;
173
- /** SMS one-time code. Default: false. */
174
- phone?: boolean;
175
- /** "Continue as guest" anonymous session. Default: false. */
176
- anonymous?: boolean;
177
- /** OAuth2 providers to show, in order. Default: []. */
178
- oauth?: OAuthProviderName[];
179
- }
180
-
181
- export declare function AuthUIModal(props: {
182
- view?: AuthUIView;
183
- open?: boolean;
184
- closeOnSuccess?: boolean;
185
- }): ReactElement;
186
-
187
- /** Something the widget must finish after a redirect, e.g. password reset. */
188
- declare type AuthUIPendingAction = {
189
- type: "reset-password";
190
- userId: string;
191
- secret: string;
192
- } | {
193
- type: "verify-email";
194
- userId: string;
195
- secret: string;
196
- } | {
197
- type: "oauth-failed";
198
- } | {
199
- type: "notice";
200
- message: string;
201
- tone: "success" | "error" | "info";
202
- };
203
-
204
- /** Configures Auth UI once and renders children. Put it near the root of your app. */
205
- export declare function AuthUIProvider({ config, children, }: {
206
- config: AuthUIConfig;
207
- children?: ReactNode;
208
- }): ReactElement;
209
-
210
- declare type AuthUIRadius = "none" | "sm" | "md" | "lg" | "xl" | "full";
211
-
212
- export declare function AuthUISignIn(props: {
213
- view?: Exclude<AuthUIView, "account">;
214
- onSuccess?: () => void;
215
- }): ReactElement;
216
-
217
- declare interface AuthUIState {
218
- status: AuthUIStatus;
219
- user: Models.User<Models.Preferences> | null;
220
- /** Factors available to complete MFA when status is "mfa-required". */
221
- mfaFactors: Models.MfaFactors | null;
222
- pending: AuthUIPendingAction | null;
223
- configured: boolean;
224
- }
225
-
226
- declare type AuthUIStatus = "loading" | "signed-out" | "signed-in" | "mfa-required";
227
-
228
- declare interface AuthUIStrings {
229
- signIn: string;
230
- signUp: string;
231
- signOut: string;
232
- continueAsGuest: string;
233
- email: string;
234
- password: string;
235
- newPassword: string;
236
- confirmPassword: string;
237
- name: string;
238
- phone: string;
239
- code: string;
240
- forgotPassword: string;
241
- noAccount: string;
242
- haveAccount: string;
243
- or: string;
244
- continueWith: string;
245
- continueWithEmail: string;
246
- sendEmailCode: string;
247
- continueWithPhone: string;
248
- sendMagicLink: string;
249
- sendCode: string;
250
- verifyCode: string;
251
- magicLinkSent: string;
252
- codeSent: string;
253
- securityPhrase: string;
254
- securityPhraseHint: string;
255
- back: string;
256
- cancel: string;
257
- save: string;
258
- update: string;
259
- remove: string;
260
- close: string;
261
- resetPassword: string;
262
- resetLinkSent: string;
263
- passwordUpdated: string;
264
- sendResetLink: string;
265
- agreeTo: string;
266
- terms: string;
267
- privacy: string;
268
- and: string;
269
- welcomeBack: string;
270
- createAccount: string;
271
- signInTitle: string;
272
- signUpTitle: string;
273
- mfaTitle: string;
274
- mfaDescription: string;
275
- mfaUseAuthenticator: string;
276
- mfaUseEmail: string;
277
- mfaUsePhone: string;
278
- mfaUseRecoveryCode: string;
279
- recoveryCode: string;
280
- account: string;
281
- profile: string;
282
- security: string;
283
- sessions: string;
284
- connections: string;
285
- activity: string;
286
- dangerZone: string;
287
- verified: string;
288
- unverified: string;
289
- verifyEmail: string;
290
- verificationSent: string;
291
- emailVerified: string;
292
- changePassword: string;
293
- currentPassword: string;
294
- twoFactor: string;
295
- twoFactorDescription: string;
296
- enable: string;
297
- disable: string;
298
- authenticatorApp: string;
299
- authenticatorAdd: string;
300
- authenticatorScan: string;
301
- authenticatorManual: string;
302
- authenticatorVerify: string;
303
- recoveryCodes: string;
304
- recoveryCodesDescription: string;
305
- generateRecoveryCodes: string;
306
- regenerateRecoveryCodes: string;
307
- recoveryCodesWarning: string;
308
- currentSession: string;
309
- signOutSession: string;
310
- signOutAllSessions: string;
311
- signOutAllSessionsDescription: string;
312
- noConnections: string;
313
- disconnect: string;
314
- noActivity: string;
315
- deleteAccount: string;
316
- deleteAccountDescription: string;
317
- deleteAccountConfirm: string;
318
- loading: string;
319
- copied: string;
320
- copy: string;
321
- done: string;
322
- errorGeneric: string;
323
- errorInvalidCredentials: string;
324
- errorUserExists: string;
325
- errorUserBlocked: string;
326
- errorRateLimit: string;
327
- errorInvalidToken: string;
328
- errorInvalidCode: string;
329
- errorPasswordMismatch: string;
330
- errorPasswordRecentlyUsed: string;
331
- errorPasswordPersonalData: string;
332
- errorPasswordWeak: string;
333
- errorPasswordPwned: string;
334
- errorChallengeRequired: string;
335
- errorSessionExists: string;
336
- errorOAuth: string;
337
- errorNetwork: string;
338
- errorMethodDisabled: string;
339
- errorNotConfigured: string;
340
- passwordHint: string;
341
- signedInAs: string;
342
- manageAccount: string;
343
- continue: string;
344
- provider: string;
345
- lastActive: string;
346
- guestAccount: string;
347
- guestAccountDescription: string;
348
- }
349
-
350
- declare type AuthUITheme = "light" | "dark" | "auto";
351
-
352
- export declare function AuthUIUserButton(props: {
353
- src?: string;
354
- children?: ReactNode;
355
- }): ReactElement;
356
-
357
- /** Screens the widget can show. */
358
- declare type AuthUIView = "sign-in" | "sign-up" | "forgot-password" | "reset-password" | "magic-url" | "email-otp" | "phone" | "mfa" | "account";
359
-
360
- declare function closeModal(): void;
361
-
362
- declare type Listener<K extends AuthUIEventName> = (detail: AuthUIEventMap[K]) => void;
363
-
364
- declare type MfaFactor = "totp" | "email" | "phone" | "recoverycode";
365
-
366
- /** Every OAuth2 provider slug Appwrite understands. */
367
- 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";
368
-
369
- /**
370
- * Open the modal from anywhere. If no <authui-modal> exists yet, one is appended to <body>.
371
- */
372
- declare function openModal(view?: AuthUIView): void;
373
-
374
- export declare function SignedIn({ children }: {
375
- children?: ReactNode;
376
- }): ReactElement;
377
-
378
- export declare function SignedOut({ children }: {
379
- children?: ReactNode;
380
- }): ReactElement;
381
-
382
- /** Subscribe to Auth UI state and get the imperative helpers. */
383
- export declare function useAuthUI(): {
384
- open: typeof openModal;
385
- close: typeof closeModal;
386
- signOut: () => Promise<void>;
387
- store: AuthStore;
388
- status: AuthUIStatus;
389
- user: Models.User<Models.Preferences> | null;
390
- mfaFactors: Models.MfaFactors | null;
391
- pending: AuthUIPendingAction | null;
392
- configured: boolean;
393
- };
394
-
395
- export { }