@passflow/react 0.27.0 → 0.28.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.
- package/CHANGELOG.md +12 -0
- package/README.md +17 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +104 -104
- package/dist/index.es.js.map +1 -1
- package/dist/src/components/login-button/index.d.cts +6 -2
- package/dist/src/components/login-button/index.d.ts +6 -2
- package/dist/src/components/login-button/index.d.ts.map +1 -1
- package/dist/src/components/provider/passflow-provider.d.ts.map +1 -1
- package/dist/src/components/provider/upgrade-provider.d.cts +1 -1
- package/dist/src/components/provider/upgrade-provider.d.ts +1 -1
- package/dist/src/components/provider/upgrade-provider.d.ts.map +1 -1
- package/dist/src/dev-account.d.ts.map +1 -1
- package/dist/src/hooks/use-auth-cloud-redirect.d.ts.map +1 -1
- package/dist/src/index.d.cts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/utils/hosted-sign-in.d.cts +20 -0
- package/dist/src/utils/hosted-sign-in.d.ts +20 -0
- package/dist/src/utils/hosted-sign-in.d.ts.map +1 -0
- package/dist/src/utils/index.d.cts +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@passflow/react` are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.28.0] - 2026-11-21
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- A hosted sign-in started by the SDK now asks to return to the app root, `${origin}/`, instead of the page it started on. That covers `LoginButton`, the default step-up sign-in, the "Sign in again" action and `useAuthCloudRedirect`. After the sign-in, `PassflowProvider` takes the user back to the page they started on. Register `${origin}/` as a redirect URL of the app. Before, a sign-in started on a page such as `/account/settings` asked to return to that page and the hosted login refused it with "redirect_uri not registered for this client" unless that exact page was registered.
|
|
10
|
+
- A hosted sign-out with no `postLogoutRedirectUri` now returns to `${origin}/` too, since it defaults to the address the sign-in returned to.
|
|
11
|
+
- A `redirectUrl` passed in `authRedirectOptions` (or to `startHostedSignIn()`) is used as before, and the user stays where it lands. An app served under a sub-path (Vite `base: '/app/'`) passes `redirectUrl`, such as `${origin}/app/`, to `LoginButton`'s `authRedirectOptions` or to `startHostedSignIn()`, since the origin root is not its page.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `startHostedSignIn(passflow, options?)` starts the hosted sign-in the same way, for an app with its own sign-in button.
|
|
16
|
+
|
|
5
17
|
## [0.27.0] - 2026-11-21
|
|
6
18
|
|
|
7
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -321,7 +321,7 @@ import { LoginButton } from '@passflow/react';
|
|
|
321
321
|
<LoginButton />;
|
|
322
322
|
```
|
|
323
323
|
|
|
324
|
-
Signed out, it shows **Sign in** (`signInLabel`) and a click starts the hosted sign-in, `passflow
|
|
324
|
+
Signed out, it shows **Sign in** (`signInLabel`) and a click starts the hosted sign-in, `startHostedSignIn(passflow, authRedirectOptions)`. Signed in, it shows the user's email (`signedInLabel={(user) => …}`) and a click signs out with `useAuth().logout()`, which also ends the hosted session after a hosted sign-in; `postLogoutRedirectUri` says where the browser lands. The button is disabled and `aria-busy` while the sign-out is in flight, and it switches on sign-in and sign-out events.
|
|
325
325
|
|
|
326
326
|
To use your own button, wrap it. Your element becomes the button: it keeps its props, content and look, and gets a click handler that calls its own `onClick` first, then signs in or out unless that called `event.preventDefault()` (a component that calls `onClick()` with no event still signs in or out). No label is injected, so its text stays as you wrote it. While the sign-out is in flight it gets `disabled` and `aria-busy`; otherwise those stay as you passed them. For text that switches, pass a function, which also receives `busy`:
|
|
327
327
|
|
|
@@ -339,6 +339,19 @@ In an app styled with shadcn/ui, `appearance="shadcn"` takes `--primary`, `--pri
|
|
|
339
339
|
<LoginButton appearance='shadcn' />
|
|
340
340
|
```
|
|
341
341
|
|
|
342
|
+
#### Where the hosted sign-in returns
|
|
343
|
+
|
|
344
|
+
The redirect URL the SDK sends is the app root, `${origin}/`, unless `authRedirectOptions.redirectUrl` is given. Register `${origin}/` as a redirect URL of the app. The page the user started on is kept in sessionStorage, and once the provider has taken the sign-in at `/` it navigates back there with `replace`, so a sign-in started on `/account/settings?tab=2` ends on that page. A `redirectUrl` you pass is sent as it is, and the user lands there instead. An app served under a sub-path (Vite `base: '/app/'`) is not at the origin root, so it passes its own `redirectUrl`, such as `${origin}/app/`, in `LoginButton`'s `authRedirectOptions` or to `startHostedSignIn()`.
|
|
345
|
+
|
|
346
|
+
Every hosted sign-in the SDK starts works this way: `LoginButton`, `useAuthCloudRedirect`, and the step-up and "sign in again" fallbacks. For a button of your own, call the same function:
|
|
347
|
+
|
|
348
|
+
```tsx
|
|
349
|
+
import { startHostedSignIn, usePassflow } from '@passflow/react';
|
|
350
|
+
|
|
351
|
+
const passflow = usePassflow();
|
|
352
|
+
<button type='button' onClick={() => void startHostedSignIn(passflow)}>Sign in</button>;
|
|
353
|
+
```
|
|
354
|
+
|
|
342
355
|
### Two-factor setup for a signed-in user
|
|
343
356
|
|
|
344
357
|
When the app's two-factor policy is **Optional**, sign-in does not ask the user to set up an authenticator. Let a signed-in user turn it on from your own page with one component:
|
|
@@ -373,7 +386,7 @@ The dialog offers the factors the server lists in `available_factors`, in its or
|
|
|
373
386
|
| Rate limited | "Too many attempts. Try again in 30 seconds.", with the wait in seconds, minutes, hours or days, rounded up ("15 minutes", "1 day"), or the server's own text when it names no wait. No new code is asked for. |
|
|
374
387
|
| Insufficient (verified, but the call was challenged again) | The levels reached and required, with **Sign in again**, which calls `upgrade.onSignInRequired`. |
|
|
375
388
|
|
|
376
|
-
`upgrade.onSignInRequired` is where those sign-ins go. By default it opens the app's own sign-in route when a `PassflowFlow` is mounted, and otherwise calls `passflow
|
|
389
|
+
`upgrade.onSignInRequired` is where those sign-ins go. By default it opens the app's own sign-in route when a `PassflowFlow` is mounted, and otherwise calls `startHostedSignIn(passflow)`. Pass your own to send the user somewhere else:
|
|
377
390
|
|
|
378
391
|
```tsx
|
|
379
392
|
<PassflowProvider {...config} upgrade={{ interceptFetch: true, onSignInRequired: () => router.navigate('/login') }}>
|
|
@@ -889,7 +902,8 @@ When the user signed in through the hosted login (`authRedirect()`), `logout()`
|
|
|
889
902
|
```tsx
|
|
890
903
|
const { logout } = useAuth();
|
|
891
904
|
|
|
892
|
-
// Must match one of the app's registered redirect URLs. Default: the address the hosted sign-in landed on
|
|
905
|
+
// Must match one of the app's registered redirect URLs. Default: the address the hosted sign-in landed on, the app root
|
|
906
|
+
// when the SDK started it.
|
|
893
907
|
await logout({ postLogoutRedirectUri: 'https://app.example.com/signed-out' });
|
|
894
908
|
```
|
|
895
909
|
|