ab-ecosystem-sso 0.1.12 → 0.1.14

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/README.md CHANGED
@@ -13,7 +13,7 @@ Drop-in React auth & account UI for the partner-ecosystem **Auth-as-a-Service**
13
13
 
14
14
  - [Installation](#installation)
15
15
  - [Configuration basics](#configuration-basics)
16
- - [Auth screens](#auth-screens) — `Login` · `Signup` · `ForgotPassword`
16
+ - [Auth screens](#auth-screens) — `Login` · `Signup` · `ForgotPassword` · `VerifyEmail`
17
17
  - [Session management](#session-management) — `SessionProvider`, enforce subscription
18
18
  - [Account Settings modal](#account-settings-modal) — `openAccountSettings` / `AccountSettings`
19
19
  - [Logout](#logout) — `logout` · `LogoutButton` · `logoutApi`
@@ -86,6 +86,8 @@ function LoginPage() {
86
86
 
87
87
  `Login` first fetches the project's `auth-config` (captcha provider/site-key, branding, which links to show) and renders accordingly. If the account has **2FA** enabled it automatically shows a **segmented 6-digit OTP** step (with captcha when the project requires it), and only calls `onSuccess` after verification succeeds.
88
88
 
89
+ **Magic-link sign-in** works automatically: point your magic link at `/login#<access_token>` (a bare `/login#access_token=<token>` is also accepted). On mount, `Login` reads the token from the URL hash, validates it with a `/me` call, and — if valid — strips it from the URL and fires `onSuccess({ token, user })`, exactly like a password sign-in. While it validates, a loading state shows; if the token is invalid or expired, it falls back to the normal sign-in form with a short notice (and calls `onError`). No extra wiring needed beyond routing the link to your login page.
90
+
89
91
  ### `Signup` and `ForgotPassword`
90
92
 
91
93
  ```tsx
@@ -95,6 +97,41 @@ import { Signup, ForgotPassword } from "ab-ecosystem-sso";
95
97
  <ForgotPassword projectId="…" onBackToLogin={() => navigate("/login")} />
96
98
  ```
97
99
 
100
+ ### `VerifyEmail`
101
+
102
+ The email-verification screen for a `/verify/:token` route — the link you email to new users. It shows a captcha (site key from the project's auth-config), then posts the captcha + token to `/auth/verify-email`.
103
+
104
+ ```tsx
105
+ import { VerifyEmail } from "ab-ecosystem-sso";
106
+
107
+ // e.g. React Router: <Route path="/verify/:token" element={<VerifyPage />} />
108
+ function VerifyPage() {
109
+ const { token } = useParams();
110
+ return (
111
+ <VerifyEmail
112
+ projectId="your-project-id"
113
+ apiBaseUrl="https://your-api"
114
+ token={token}
115
+ onVerified={() => navigate("/login")}
116
+ onLoginClick={() => navigate("/login")}
117
+ onSignupClick={() => navigate("/signup")}
118
+ onError={(err) => console.error(err)}
119
+ />
120
+ );
121
+ }
122
+ ```
123
+
124
+ On success it calls `onVerified` (send the user to login) and shows a **Continue to sign in** button. On failure it shows a **Verification failed** card with the reason plus **Go to sign in** / **Go to sign up** buttons. Verification counts as successful only when the response is 2xx **and** `success: true`.
125
+
126
+ | Prop | Type | Notes |
127
+ | --- | --- | --- |
128
+ | `token` | `string` | The token from your route params. Falls back to the last path segment of the URL. |
129
+ | `onVerified` | `() => void` | Fires once the email is verified. |
130
+ | `onLoginClick` | `() => void` | Navigate to login (shown on success and failure). |
131
+ | `onSignupClick` | `() => void` | Navigate to signup (shown on failure). |
132
+
133
+ > Prefer passing `token` from your router. The URL fallback only exists so the component works on a plain `/verify/:token` page with no router wired up.
134
+
98
135
  ### Shared auth props
99
136
 
100
137
  | Prop | Type | Notes |
@@ -106,7 +143,7 @@ import { Signup, ForgotPassword } from "ab-ecosystem-sso";
106
143
  | `onError` | `(error: Error) => void` | On failure. |
107
144
  | `classNames` | `AuthClassNames` | Per-element class overrides: `card`, `input`, `label`, `button`, `link`, `captcha`, `error`, … |
108
145
 
109
- Per-screen extras: `Login` adds `onForgotPassword` / `onSignupClick`; `Signup` adds `onLoginClick`; `ForgotPassword` adds `onBackToLogin`.
146
+ Per-screen extras: `Login` adds `onForgotPassword` / `onSignupClick`; `Signup` adds `onLoginClick`; `ForgotPassword` adds `onBackToLogin`; `VerifyEmail` adds `token` / `onVerified` / `onLoginClick` / `onSignupClick` (and has no `onSuccess`, since no session is created).
110
147
 
111
148
  ---
112
149
 
@@ -363,6 +400,7 @@ Beyond the components, these functions are exported for building custom UIs:
363
400
  | Function | Endpoint |
364
401
  | --- | --- |
365
402
  | `getAuthConfig(projectId, apiBaseUrl?)` | `GET /auth-config` → `AuthConfig` (captcha, branding, card layout; no token) |
403
+ | `verifyEmailApi(projectId, { token, captchaToken }, apiBaseUrl?)` | `POST /auth/verify-email` |
366
404
  | `getUser(projectId, token, apiBaseUrl?)` | `GET /me` (raw envelope) |
367
405
  | `getUserProfile(projectId, token, apiBaseUrl?)` | `GET /me` → `MappedProfile` |
368
406
  | `getUserWallet(projectId, token, apiBaseUrl?)` | `GET /me` → `UserWallets` |
@@ -381,7 +419,7 @@ Everything is fully typed. Notable exports:
381
419
 
382
420
  ```ts
383
421
  import type {
384
- LoginProps, SignupProps, ForgotPasswordProps, AuthClassNames,
422
+ LoginProps, SignupProps, ForgotPasswordProps, VerifyEmailProps, AuthClassNames,
385
423
  AccountSettingsProps, AccountSettingsSection, AccountSettingsData, ProfileFormValues,
386
424
  OpenAccountSettingsOptions, AccountSettingsHandle,
387
425
  AuthConfig, CaptchaConfig, CardLayoutConfig,