ab-ecosystem-sso 0.1.11 → 0.1.13

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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { JSX as JSX_2 } from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
 
4
- export declare function AccountSettings({ open, onOpenChange, initialSection, data, title, projectId, token, apiBaseUrl, onSaveProfile, onUpdateWhatsApp, onChangePassword, onToggleTwoFactor, onRevokeSession, onAddFunds, onChangePlan, onLogout, }: AccountSettingsProps): JSX_2.Element | null;
4
+ export declare function AccountSettings({ open, onOpenChange, initialSection, syncUrlHash, data, title, projectId, token, apiBaseUrl, onSaveProfile, onUpdateWhatsApp, onChangePassword, onToggleTwoFactor, onRevokeSession, onAddFunds, onChangePlan, onLogout, }: AccountSettingsProps): JSX_2.Element | null;
5
5
 
6
6
  export declare interface AccountSettingsData {
7
7
  user: {
@@ -85,6 +85,12 @@ export declare interface AccountSettingsProps {
85
85
  onOpenChange: (open: boolean) => void;
86
86
  /** Section to show first. Defaults to "general". */
87
87
  initialSection?: AccountSettingsSection;
88
+ /**
89
+ * Sync the open state + active section to the URL hash as `#settings-<section>`,
90
+ * so a page refresh re-opens the modal on the same section. The hash is cleared
91
+ * when the modal closes. Defaults to `true`; set `false` to leave the URL alone.
92
+ */
93
+ syncUrlHash?: boolean;
88
94
  /** Override any slice of the built-in sample data. Provided slices replace the defaults. */
89
95
  data?: Partial<AccountSettingsData>;
90
96
  /** Modal heading shown above the nav. Defaults to "Settings". */
@@ -224,6 +230,10 @@ export declare interface CreditWallet {
224
230
  rechargeable: boolean;
225
231
  }
226
232
 
233
+ declare function fetchAuthConfig(projectId: string, apiBaseUrl?: string): Promise<AuthConfig>;
234
+ export { fetchAuthConfig }
235
+ export { fetchAuthConfig as getAuthConfig }
236
+
227
237
  export declare function ForgotPassword(props: ForgotPasswordProps): JSX_2.Element;
228
238
 
229
239
  export declare interface ForgotPasswordProps extends AuthComponentBaseProps {
@@ -384,6 +394,12 @@ export declare type OpenAccountSettingsOptions = Omit<AccountSettingsProps, "ope
384
394
  onClose?: () => void;
385
395
  };
386
396
 
397
+ /**
398
+ * Reads the current URL hash and returns the settings section it encodes, or
399
+ * `null` if the hash isn't a `#settings-<section>` value we recognise.
400
+ */
401
+ export declare function parseSettingsHash(): AccountSettingsSection | null;
402
+
387
403
  export declare interface ProfileFormValues {
388
404
  firstName: string;
389
405
  lastName: string;
@@ -400,6 +416,19 @@ export declare interface ProfileFormValues {
400
416
  language: string;
401
417
  }
402
418
 
419
+ /**
420
+ * Re-opens the Account Settings modal if the current URL hash points at it
421
+ * (`#settings-<section>`) — call this once on app load so an imperatively-opened
422
+ * modal survives a page refresh. Returns the modal handle if it was opened, or
423
+ * `null` when there's no settings hash to restore.
424
+ *
425
+ * import { restoreAccountSettings } from "ab-ecosystem-sso";
426
+ * useEffect(() => { restoreAccountSettings({ projectId, token, apiBaseUrl }); }, []);
427
+ *
428
+ * The section comes from the hash; any `initialSection` in `options` is ignored.
429
+ */
430
+ export declare function restoreAccountSettings(options?: OpenAccountSettingsOptions): AccountSettingsHandle | null;
431
+
403
432
  declare interface SessionContextValue {
404
433
  isAuthenticated: boolean;
405
434
  isValidating: boolean;
@@ -424,6 +453,9 @@ declare interface SessionProviderProps {
424
453
  children: ReactNode;
425
454
  }
426
455
 
456
+ /** Every section that can appear in the hash. Order is not significant. */
457
+ export declare const SETTINGS_SECTIONS: AccountSettingsSection[];
458
+
427
459
  export declare function Signup(props: SignupProps): JSX_2.Element;
428
460
 
429
461
  export declare interface SignupProps extends AuthComponentBaseProps {
@@ -482,6 +514,58 @@ export declare interface UserWallets {
482
514
 
483
515
  export declare function useSession(): SessionContextValue;
484
516
 
517
+ /**
518
+ * Email-verification screen for a `/verify/:token` route.
519
+ *
520
+ * <VerifyEmail
521
+ * projectId="…"
522
+ * token={params.token}
523
+ * onVerified={() => navigate("/login")}
524
+ * onLoginClick={() => navigate("/login")}
525
+ * onSignupClick={() => navigate("/signup")}
526
+ * />
527
+ */
528
+ export declare function VerifyEmail(props: VerifyEmailProps): JSX_2.Element;
529
+
530
+ /**
531
+ * POST /auth/verify-email — confirms an email address using the token from the
532
+ * verification link, plus a captcha token when the project requires one.
533
+ *
534
+ * The endpoint can answer HTTP 200 with `{ success: false }`, so a successful
535
+ * verification requires BOTH a 2xx status and `success === true`; anything else
536
+ * throws AuthApiError.
537
+ */
538
+ export declare function verifyEmailApi(projectId: string, data: VerifyEmailRequest, apiBaseUrl?: string): Promise<VerifyEmailResponse>;
539
+
540
+ /**
541
+ * Email-verification screen for a `/verify/:token` route. `onSuccess` doesn't
542
+ * apply here (no session is created), so it's omitted in favour of `onVerified`.
543
+ */
544
+ export declare interface VerifyEmailProps extends Omit<AuthComponentBaseProps, "onSuccess"> {
545
+ /**
546
+ * The verification token from the `/verify/:token` route — pass it from your
547
+ * router's params. Falls back to the last segment of `window.location.pathname`.
548
+ */
549
+ token?: string;
550
+ /** Called once the email is verified — send the user to your login route here. */
551
+ onVerified?: () => void;
552
+ /** Navigate to your login route (shown on success and on failure). */
553
+ onLoginClick?: () => void;
554
+ /** Navigate to your signup route (shown on failure). */
555
+ onSignupClick?: () => void;
556
+ }
557
+
558
+ export declare interface VerifyEmailRequest {
559
+ /** The verification token from the emailed link (the `/verify/:token` path param). */
560
+ token: string;
561
+ captchaToken?: string;
562
+ }
563
+
564
+ export declare interface VerifyEmailResponse {
565
+ success: boolean;
566
+ message?: string;
567
+ }
568
+
485
569
  export declare interface VerifyTwoFactorRequest {
486
570
  email: string;
487
571
  password: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ab-ecosystem-sso",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "main": "dist/ab-ecosystem-sso.cjs",
6
6
  "module": "dist/ab-ecosystem-sso.js",