@lenne.tech/nuxt-extensions 4.0.2 → 4.0.4
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/CLAUDE.md +63 -5
- package/README.md +90 -3
- package/dist/module.d.mts +1 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/auth/use-lt-auth.js +34 -10
- package/dist/runtime/lib/auth-client.d.ts +13 -1
- package/dist/runtime/lib/auth-client.js +13 -1
- package/dist/runtime/lib/auth-state.d.ts +54 -2
- package/dist/runtime/lib/auth-state.js +37 -1
- package/dist/runtime/middleware/setup.d.ts +1 -1
- package/dist/runtime/plugins/auth-interceptor.client.d.ts +1 -1
- package/dist/runtime/plugins/error-translation.client.d.ts +1 -1
- package/dist/runtime/plugins/form-label-association.client.d.ts +1 -1
- package/dist/runtime/plugins/lt-config-check.d.ts +1 -1
- package/dist/runtime/plugins/pre-hydration-input.client.d.ts +1 -1
- package/dist/runtime/types/auth.d.ts +63 -1
- package/dist/runtime/types/index.d.ts +1 -1
- package/package.json +10 -10
package/CLAUDE.md
CHANGED
|
@@ -25,8 +25,8 @@ src/
|
|
|
25
25
|
|
|
26
26
|
| Composable | Purpose |
|
|
27
27
|
|-----------|---------|
|
|
28
|
-
| `useLtAuth()` | Authentication state, login, logout, session management, password change + reset |
|
|
29
|
-
| `useLtAuthClient()` | Raw Better Auth client access (`twoFactor.*`, `admin.*`, `passkey`) |
|
|
28
|
+
| `useLtAuth()` | Authentication state, login (password, passkey, social provider), logout, session management, password change + reset |
|
|
29
|
+
| `useLtAuthClient()` | Raw Better Auth client access (`twoFactor.*`, `admin.*`, `passkey`, `signIn.social`) |
|
|
30
30
|
| `useSystemSetup()` | First-admin setup flow: status, HTTP-setup release + setup token (nest-server >= 12.4.0) |
|
|
31
31
|
| `useLtTusUpload()` | TUS resumable file uploads |
|
|
32
32
|
| `useLtFile()` | File utilities (size formatting; file links on the API, the public URL also during SSR) |
|
|
@@ -128,6 +128,7 @@ of `useLtFile()` use the browser's address during SSR too.
|
|
|
128
128
|
- Protected-route gating is the consumer's own middleware (see "Custom Auth Middleware Pattern" below); the module only registers the optional `lt-system-setup` middleware
|
|
129
129
|
- Passkey (WebAuthn) support via `@better-auth/passkey` peer dependency
|
|
130
130
|
- 2FA (TOTP) support built-in
|
|
131
|
+
- Sign-in through a social provider the API configured (`signIn.social`, see below)
|
|
131
132
|
|
|
132
133
|
### Auth Flow
|
|
133
134
|
|
|
@@ -156,6 +157,18 @@ renewed an expired JWT. Do not write a third one; a caller with its own state pa
|
|
|
156
157
|
- **The JWT comes from `auth.basePath`.** Without an argument, `ltAuthFetch`, `createLtAuthFetch()`
|
|
157
158
|
and `attemptLtJwtSwitch()` read it from the runtime config. `requestLtJwt()` is the only place a
|
|
158
159
|
JWT is fetched, `useLtAuth().switchToJwtMode()` included.
|
|
160
|
+
- **An API that reports `jwt: false` in `/features` is never asked for a JWT.** nest-server with
|
|
161
|
+
`betterAuth.jwt: false` answers `/token` with 404; before this, every sign-in, session check and
|
|
162
|
+
401 cost one 404 with a console error. `fetchFeatures()` hands its request to
|
|
163
|
+
`noteLtJwtServedBy()`, and `requestLtJwt()` returns `null` without a request once the answer said
|
|
164
|
+
`false`. It awaits a features request still in flight (at app start `validateSession()` asks for
|
|
165
|
+
the JWT while it is). Features an SSR render fetched (the starter's register page) reach the
|
|
166
|
+
client in the payload, and the client fetches none of its own: `useLtAuth()` then hands the
|
|
167
|
+
payload state to `noteLtJwtServedByPayload()`, which counts only while nothing in the tab was
|
|
168
|
+
noted, so a second `useLtAuth()` call never replaces a request in flight. Client only; a missing
|
|
169
|
+
flag or a failed request keeps today's behaviour.
|
|
170
|
+
No module option on purpose: the API is the one source, and a second switch in the app could
|
|
171
|
+
disagree with it. `test/jwt-disabled-api.test.ts` holds this.
|
|
159
172
|
|
|
160
173
|
## AI Assistant Flow
|
|
161
174
|
|
|
@@ -279,9 +292,9 @@ unchanged. That token is the session token, the value the API keeps in the httpO
|
|
|
279
292
|
- **`setUser(user, 'jwt')` without a stored JWT falls back to `'cookie'`** and fetches the JWT.
|
|
280
293
|
Without that fallback, the refusal above would turn a hand-written 2FA page into a sign-in that
|
|
281
294
|
sends no credentials at all.
|
|
282
|
-
- **`useLtAuthClient().twoFactor.verify*`
|
|
283
|
-
`authenticateWithPasskey()` returns no `session`. Keep
|
|
284
|
-
receives the session token cannot store it.
|
|
295
|
+
- **`useLtAuthClient().twoFactor.verify*` and `signIn.social` strip a non-JWT `token` from the
|
|
296
|
+
answer**, and `authenticateWithPasskey()` returns no `session`. Keep all three: application code
|
|
297
|
+
that never receives the session token cannot store it.
|
|
285
298
|
|
|
286
299
|
### How Auth Cookies Work:
|
|
287
300
|
1. `setUser()` writes the cookie via both `useCookie().value` (for SSR sync) and `document.cookie` (for immediate availability)
|
|
@@ -327,6 +340,51 @@ export default defineNuxtRouteMiddleware((to) => {
|
|
|
327
340
|
});
|
|
328
341
|
```
|
|
329
342
|
|
|
343
|
+
## Social Sign-In (`signIn.social`, since 4.0.3)
|
|
344
|
+
|
|
345
|
+
`useLtAuth().signIn.social(params)` signs in through a provider the API configured
|
|
346
|
+
(`betterAuth.socialProviders` in nest-server; first use: Microsoft Entra ID as single sign-on).
|
|
347
|
+
`GET /iam/features` lists the enabled providers as `socialProviders`, which `useLtAuth().features`
|
|
348
|
+
holds. `useLtAuthClient().signIn.social` is the same call without the auth state. Parameters:
|
|
349
|
+
`LtSocialSignInParams` in `runtime/types/auth.ts`.
|
|
350
|
+
|
|
351
|
+
- **Redirect shape (no `idToken`): the page is left.** The answer is the provider's authorization
|
|
352
|
+
URL and Better Auth's client navigates there; nothing is stored. The API's callback sets the
|
|
353
|
+
session cookie and redirects to `callbackURL`, where the user arrives through `validateSession()`.
|
|
354
|
+
- **ID-token shape: signed in at once.** For an app inside a host that already knows the user
|
|
355
|
+
(Microsoft Teams, a native shell). The answer is `{ token, user }`; the wrapper strips the session
|
|
356
|
+
token, and `completeForwardedSignIn()` signs the user in on the cookie session and fetches the
|
|
357
|
+
JWT from `/iam/token`, exactly as after 2FA. `withoutSessionToken` strips only `result.data`, as
|
|
358
|
+
for 2FA: with `throw: true` (as `options` or in `fetchOptions`) the body comes back with the
|
|
359
|
+
token, and a caller's `onSuccess` hook sees the answer before the token is removed.
|
|
360
|
+
- **Silent attempt: `additionalParams: { prompt: 'none' }`.** The provider answers without showing
|
|
361
|
+
anything, and the way back without a provider session is `errorCallbackURL` with
|
|
362
|
+
`?error=login_required` (or `interaction_required`). A page that starts the attempt on load must
|
|
363
|
+
remember per tab that it tried, and must not try after an explicit sign-out; otherwise it loops
|
|
364
|
+
or signs the user straight back in. nuxt-base-starter's login page shows the pattern.
|
|
365
|
+
- **`?error=` is a code; map it, never render the query.** The provider's own codes
|
|
366
|
+
(`access_denied`, `consent_required`, …) and Better Auth's (`signup_disabled`, …) arrive there,
|
|
367
|
+
next to an `error_description` anybody can write into a link.
|
|
368
|
+
- **`callbackURL` / `errorCallbackURL` must be absolute URLs of a trusted origin, never user
|
|
369
|
+
input.** Same reasoning as `redirectTo` below: Better Auth resolves a relative value against the
|
|
370
|
+
API origin, and `trustedOrigins` is the only check on the result. Build both from the app's own
|
|
371
|
+
origin and a fixed path (`appUrl()` in the starters); a deep link goes into their query only after
|
|
372
|
+
`safeRedirectTarget()`.
|
|
373
|
+
- **Nothing is hashed.** No credential travels, so the parameters go through unchanged; the
|
|
374
|
+
wrapper changes only the answer. `test/auth-client-social-sign-in.test.ts`,
|
|
375
|
+
`test/social-sign-in-session.test.ts` and the `signIn.social` case in
|
|
376
|
+
`test/better-auth-contract.test.ts` (real better-auth client, stubbed `fetch`) hold this.
|
|
377
|
+
|
|
378
|
+
**An inline image never reaches the auth state.** Better Auth's Microsoft provider stores the
|
|
379
|
+
profile photo in `user.image` as a `data:` URL. In `lt-auth-state` a few KB of it push the cookie
|
|
380
|
+
past the browser's 4096 bytes, the browser drops it without an error, and the next page load reads
|
|
381
|
+
as a logout (with a silent sign-in on the login page: a loop through app, API and provider). Every
|
|
382
|
+
writer of the auth state goes through `toLtStoredAuthState()` in `lib/auth-state.ts`, which leaves a
|
|
383
|
+
`data:` image out at any size and keeps an `http(s)` URL or a path; `user.value.image` is then
|
|
384
|
+
`undefined`, and an app reads the photo from `GET <basePath>/get-session`. An API that does not need
|
|
385
|
+
the photo sets `disableProfilePhoto: true` on the Microsoft provider. A new writer of the auth state
|
|
386
|
+
uses the same function. `test/auth-state-inline-image.test.ts` emulates the browser's limit.
|
|
387
|
+
|
|
330
388
|
## Password Handling: Reset, Change, and Client-Side Hashing
|
|
331
389
|
|
|
332
390
|
**Every password leaves the browser SHA256-hashed.** `auth-client.ts` wraps each Better-Auth
|
package/README.md
CHANGED
|
@@ -111,7 +111,7 @@ nuxt-extensions release it pins.
|
|
|
111
111
|
|
|
112
112
|
## Features
|
|
113
113
|
|
|
114
|
-
- **Better-Auth Integration** - Login, 2FA, Passkey/WebAuthn
|
|
114
|
+
- **Better-Auth Integration** - Login, 2FA, Passkey/WebAuthn, sign-in through social providers (SSO)
|
|
115
115
|
- **Cookie/JWT Dual-Mode** - Automatic fallback from cookies to JWT
|
|
116
116
|
- **TUS File Upload** - Resumable uploads with pause/resume
|
|
117
117
|
- **Offline Sync** - Read and write offline, reconcile with the nest-server sync module (opt-in)
|
|
@@ -548,6 +548,86 @@ JWT from `/iam/token`.
|
|
|
548
548
|
session token.**
|
|
549
549
|
- **`authenticateWithPasskey()` returns no `session`.**
|
|
550
550
|
|
|
551
|
+
#### Sign-in through a social provider
|
|
552
|
+
|
|
553
|
+
`useLtAuth().signIn.social()` (since 4.0.3; `useLtAuthClient().signIn.social()` is the same call
|
|
554
|
+
without the auth state) signs in through a provider the API configured, for example Microsoft
|
|
555
|
+
Entra ID for single sign-on (`betterAuth.socialProviders` in nest-server). `GET /iam/features`
|
|
556
|
+
lists the enabled providers as `socialProviders`; `useLtAuth().features` holds that answer, so a
|
|
557
|
+
login page can show one button per entry.
|
|
558
|
+
|
|
559
|
+
Both shapes go to `POST <basePath>/sign-in/social`:
|
|
560
|
+
|
|
561
|
+
- **Redirect, the usual one.** The answer is the provider's authorization URL, and Better Auth's
|
|
562
|
+
client navigates there: the page is left, and nothing is stored yet. The provider sends the
|
|
563
|
+
browser to the API, which sets the session cookie and redirects to `callbackURL`. The user
|
|
564
|
+
arrives through `validateSession()` on the page behind it.
|
|
565
|
+
- **ID token**, for an app inside a host that already knows the user (Microsoft Teams, a native
|
|
566
|
+
shell). With `idToken` the API answers `{ user }` at once, without navigation. `useLtAuth()` signs
|
|
567
|
+
the user in on the cookie session and fetches the JWT from `/iam/token`, as after 2FA. The
|
|
568
|
+
session token Better Auth puts into that answer is removed, as in the 2FA answers. This covers
|
|
569
|
+
the default `{ data, error }` answer only: with `throw: true` (as `options` or in `fetchOptions`)
|
|
570
|
+
the body comes back unchanged, token included, and an `onSuccess` hook sees the answer before the
|
|
571
|
+
token is removed.
|
|
572
|
+
|
|
573
|
+
```vue
|
|
574
|
+
<script setup lang="ts">
|
|
575
|
+
const { features, signIn } = useLtAuth();
|
|
576
|
+
const config = useRuntimeConfig();
|
|
577
|
+
|
|
578
|
+
const providers = computed(() => (Array.isArray(features.value.socialProviders) ? features.value.socialProviders : []));
|
|
579
|
+
|
|
580
|
+
// Interactive: the provider shows its account picker.
|
|
581
|
+
async function signInWith(provider: string) {
|
|
582
|
+
await signIn.social({
|
|
583
|
+
additionalParams: { prompt: 'select_account' },
|
|
584
|
+
callbackURL: new URL('/auth/callback', config.public.siteUrl).toString(),
|
|
585
|
+
errorCallbackURL: new URL('/auth/login', config.public.siteUrl).toString(),
|
|
586
|
+
provider,
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
</script>
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
```vue
|
|
593
|
+
<!-- pages/auth/callback.vue: the session cookie is set, the user is not loaded yet -->
|
|
594
|
+
<script setup lang="ts">
|
|
595
|
+
const { validateSession } = useLtAuth();
|
|
596
|
+
|
|
597
|
+
onMounted(async () => {
|
|
598
|
+
const signedIn = await validateSession();
|
|
599
|
+
await navigateTo(signedIn ? '/app' : '/auth/login', { replace: true });
|
|
600
|
+
});
|
|
601
|
+
</script>
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
- **A silent attempt is `additionalParams: { prompt: 'none' }`.** The provider answers without
|
|
605
|
+
showing anything: with the session when the user has one there, otherwise through
|
|
606
|
+
`errorCallbackURL` with `?error=login_required` (or `interaction_required`). That way back is the
|
|
607
|
+
only one, so the page behind it must not start the attempt again: remember it per tab, and do
|
|
608
|
+
not try silently after an explicit sign-out, or the user is signed in again at once.
|
|
609
|
+
nuxt-base-starter does both on its login page.
|
|
610
|
+
- **`?error=` on `errorCallbackURL` is a code from the provider or from Better Auth**
|
|
611
|
+
(`access_denied`, `signup_disabled`, …). Map it to your own text. Never render `error_description`
|
|
612
|
+
or anything else from the query: anybody can put text there and send the link around.
|
|
613
|
+
- **`callbackURL` and `errorCallbackURL` must be absolute URLs of a trusted origin, and never come
|
|
614
|
+
from user input.** Better Auth resolves a relative value against the API origin, like
|
|
615
|
+
`redirectTo` (see "Password Change and Reset"), and checks the result against `trustedOrigins`,
|
|
616
|
+
which is all that stands between a value from `route.query` and a redirect to another site. Build
|
|
617
|
+
both from your own origin and a fixed path; a deep link the user should land on afterwards goes
|
|
618
|
+
into their query only after it was validated (nuxt-base-starter: `safeRedirectTarget()`).
|
|
619
|
+
- `additionalParams` applies to this request only, `loginHint` suggests an account, and
|
|
620
|
+
`disableRedirect: true` answers the URL without navigating. `LtSocialSignInParams` documents every
|
|
621
|
+
field.
|
|
622
|
+
|
|
623
|
+
**An inline profile photo is not kept in the auth state.** Better Auth's Microsoft provider stores
|
|
624
|
+
the user's photo in `user.image` as a `data:` URL. In the `lt-auth-state` cookie a few KB of it push
|
|
625
|
+
the cookie past the browser's limit of 4096 bytes; the browser drops it without an error, and the
|
|
626
|
+
next page load reads as a logout. So `useLtAuth().user.value.image` is `undefined` for such a user,
|
|
627
|
+
while an `http(s)` URL or a path stays. Where you render an avatar, read the photo from the session
|
|
628
|
+
answer (`GET <basePath>/get-session`, e.g. `useLtAuthClient().getSession()`). An API that does not
|
|
629
|
+
need the photo sets `disableProfilePhoto: true` on the Microsoft provider.
|
|
630
|
+
|
|
551
631
|
#### Authenticated requests: `fetchWithAuth` and `ltAuthFetch`
|
|
552
632
|
|
|
553
633
|
`useLtAuth().fetchWithAuth` and `ltAuthFetch` (from `/lib`, also used by the Better-Auth client,
|
|
@@ -565,6 +645,13 @@ the AI composables and offline sync) run through one implementation.
|
|
|
565
645
|
- **The JWT comes from `auth.basePath`.** Without an argument, `ltAuthFetch`, `createLtAuthFetch()`
|
|
566
646
|
and `attemptLtJwtSwitch()` read it from the module config; they used to fetch it from `/iam`
|
|
567
647
|
whatever was configured. A path passed explicitly still wins.
|
|
648
|
+
- **An API without JWT is not asked for one.** When `GET <basePath>/features` reports `jwt: false`
|
|
649
|
+
(nest-server with `betterAuth.jwt: false`, whose `/token` answers 404), neither a sign-in, a
|
|
650
|
+
session check nor a 401 requests `/token`: the app stays on the cookie session, and a 401 reaches
|
|
651
|
+
the caller unchanged. Nothing to configure in the app; the features request `useLtAuth()` makes on
|
|
652
|
+
its first client-side call decides, and a JWT request at app start waits for it. Features a page
|
|
653
|
+
fetched during SSR (`await fetchFeatures()` in `import.meta.server`) count the same, from the
|
|
654
|
+
payload. An API that reports `jwt: true`, or no `jwt` at all, is asked as before.
|
|
568
655
|
|
|
569
656
|
#### Server-side rendering: backend calls are anonymous
|
|
570
657
|
|
|
@@ -1207,8 +1294,8 @@ The package works **with or without** `@nuxtjs/i18n`:
|
|
|
1207
1294
|
|
|
1208
1295
|
| Composable | Description |
|
|
1209
1296
|
|------------|-------------|
|
|
1210
|
-
| `useLtAuth()` | Better-Auth integration with session, passkey, 2FA, password change + reset |
|
|
1211
|
-
| `useLtAuthClient()` | Direct access to the Better-Auth client singleton (`twoFactor.*`, `admin.*`, `passkey`) |
|
|
1297
|
+
| `useLtAuth()` | Better-Auth integration with session, passkey, 2FA, social sign-in, password change + reset |
|
|
1298
|
+
| `useLtAuthClient()` | Direct access to the Better-Auth client singleton (`twoFactor.*`, `admin.*`, `passkey`, `signIn.social`) |
|
|
1212
1299
|
| `useLtErrorTranslation()` | Translate backend error codes to user-friendly messages |
|
|
1213
1300
|
| `useLtTusUpload()` | TUS protocol file uploads with pause/resume |
|
|
1214
1301
|
| `useLtFile()` | File utilities (size formatting, URLs) |
|
package/dist/module.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { LtExtensionsModuleOptions } from '../dist/runtime/types/index.js';
|
|
|
3
3
|
export * from '../dist/runtime/types/index.js';
|
|
4
4
|
|
|
5
5
|
declare const name = "@lenne.tech/nuxt-extensions";
|
|
6
|
-
declare const version = "4.0.
|
|
6
|
+
declare const version = "4.0.4";
|
|
7
7
|
declare const configKey = "ltExtensions";
|
|
8
8
|
declare const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
|
|
9
9
|
declare const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
3
3
|
import { SECURITY_TXT_DEFAULT_VALID_DAYS, SECURITY_TXT_DEFAULT_LANGUAGES, SECURITY_TXT_DEFAULT_CONTACT, SECURITY_TXT_PATH } from '../dist/runtime/server/lib/security-txt.js';
|
|
4
4
|
|
|
5
5
|
const name = "@lenne.tech/nuxt-extensions";
|
|
6
|
-
const version = "4.0.
|
|
6
|
+
const version = "4.0.4";
|
|
7
7
|
const configKey = "ltExtensions";
|
|
8
8
|
const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
|
|
9
9
|
const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
|
|
@@ -7,8 +7,11 @@ import {
|
|
|
7
7
|
getLtAuthCookieNames,
|
|
8
8
|
getLtJwtToken,
|
|
9
9
|
isLtJwtShaped,
|
|
10
|
+
noteLtJwtServedBy,
|
|
11
|
+
noteLtJwtServedByPayload,
|
|
10
12
|
requestLtJwt,
|
|
11
13
|
resolveLtAuthState,
|
|
14
|
+
toLtStoredAuthState,
|
|
12
15
|
warnLtAdminPluginUnserved
|
|
13
16
|
} from "../../lib/auth-state.js";
|
|
14
17
|
import { useLtAuthClient } from "../use-lt-auth-client.js";
|
|
@@ -45,7 +48,7 @@ export function useLtAuth() {
|
|
|
45
48
|
try {
|
|
46
49
|
const resolved = resolveLtAuthState(document.cookie, stateCookieName);
|
|
47
50
|
if (resolved?.user && !authState.value?.user) {
|
|
48
|
-
authState.value = resolved;
|
|
51
|
+
authState.value = toLtStoredAuthState(resolved);
|
|
49
52
|
}
|
|
50
53
|
} catch {
|
|
51
54
|
}
|
|
@@ -99,8 +102,7 @@ export function useLtAuth() {
|
|
|
99
102
|
if (mode !== requestedMode && import.meta.client && userData) {
|
|
100
103
|
void switchToJwtMode();
|
|
101
104
|
}
|
|
102
|
-
const
|
|
103
|
-
const newState = { user: normalised, authMode: mode };
|
|
105
|
+
const newState = toLtStoredAuthState({ user: userData, authMode: mode });
|
|
104
106
|
if (import.meta.client || userData) {
|
|
105
107
|
authState.value = newState;
|
|
106
108
|
}
|
|
@@ -128,7 +130,7 @@ export function useLtAuth() {
|
|
|
128
130
|
jwtToken.value = token;
|
|
129
131
|
}
|
|
130
132
|
if (authState.value && authState.value.authMode !== "jwt") {
|
|
131
|
-
authState.value = { ...authState.value, authMode: "jwt" };
|
|
133
|
+
authState.value = toLtStoredAuthState({ ...authState.value, authMode: "jwt" });
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
136
|
async function switchToJwtMode() {
|
|
@@ -211,7 +213,9 @@ export function useLtAuth() {
|
|
|
211
213
|
async function fetchFeatures() {
|
|
212
214
|
try {
|
|
213
215
|
const apiBase = getLtApiBase();
|
|
214
|
-
const
|
|
216
|
+
const request = $fetch(`${apiBase}/features`);
|
|
217
|
+
noteLtJwtServedBy(request);
|
|
218
|
+
const result = await request;
|
|
215
219
|
if (result) {
|
|
216
220
|
features.value = result;
|
|
217
221
|
featuresFetched.value = true;
|
|
@@ -245,6 +249,22 @@ export function useLtAuth() {
|
|
|
245
249
|
} finally {
|
|
246
250
|
isLoading.value = false;
|
|
247
251
|
}
|
|
252
|
+
},
|
|
253
|
+
/**
|
|
254
|
+
* Sign in through a social provider the API configured. A redirect answer carries no user and
|
|
255
|
+
* leaves the page: the user arrives with `validateSession()` on the page the provider sends the
|
|
256
|
+
* browser back to. An ID-token answer carries the user and is completed here, see
|
|
257
|
+
* `completeForwardedSignIn`.
|
|
258
|
+
*/
|
|
259
|
+
social: async (params, options) => {
|
|
260
|
+
isLoading.value = true;
|
|
261
|
+
try {
|
|
262
|
+
const result = await authClient.signIn.social(params, options);
|
|
263
|
+
await completeForwardedSignIn(result);
|
|
264
|
+
return result;
|
|
265
|
+
} finally {
|
|
266
|
+
isLoading.value = false;
|
|
267
|
+
}
|
|
248
268
|
}
|
|
249
269
|
};
|
|
250
270
|
const signUp = {
|
|
@@ -475,7 +495,7 @@ export function useLtAuth() {
|
|
|
475
495
|
isLoading.value = false;
|
|
476
496
|
}
|
|
477
497
|
}
|
|
478
|
-
async function
|
|
498
|
+
async function completeForwardedSignIn(result) {
|
|
479
499
|
const answer = result;
|
|
480
500
|
const data = answer?.data;
|
|
481
501
|
if (answer?.error || !data?.user) {
|
|
@@ -493,7 +513,7 @@ export function useLtAuth() {
|
|
|
493
513
|
isLoading.value = true;
|
|
494
514
|
try {
|
|
495
515
|
const result = await authClient.twoFactor[method](params, options);
|
|
496
|
-
await
|
|
516
|
+
await completeForwardedSignIn(result);
|
|
497
517
|
return result;
|
|
498
518
|
} finally {
|
|
499
519
|
isLoading.value = false;
|
|
@@ -504,9 +524,13 @@ export function useLtAuth() {
|
|
|
504
524
|
verifyBackupCode: verifyingTwoFactor("verifyBackupCode"),
|
|
505
525
|
verifyTotp: verifyingTwoFactor("verifyTotp")
|
|
506
526
|
};
|
|
507
|
-
if (import.meta.client
|
|
508
|
-
featuresFetched.value
|
|
509
|
-
|
|
527
|
+
if (import.meta.client) {
|
|
528
|
+
if (!featuresFetched.value) {
|
|
529
|
+
featuresFetched.value = true;
|
|
530
|
+
void fetchFeatures();
|
|
531
|
+
} else {
|
|
532
|
+
noteLtJwtServedByPayload(features.value);
|
|
533
|
+
}
|
|
510
534
|
}
|
|
511
535
|
return {
|
|
512
536
|
// Auth state
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
* source-level half so a whitelist rebuild is visible in review. If you add a wrapper that
|
|
36
36
|
* hashes something, add it to both.
|
|
37
37
|
*/
|
|
38
|
-
import type { LtAuthClientConfig } from '../types/index.js';
|
|
38
|
+
import type { LtAuthClientConfig, LtSocialSignInParams } from '../types/index.js';
|
|
39
39
|
/**
|
|
40
40
|
* Register additional Better Auth plugins before auth client initialization.
|
|
41
41
|
*
|
|
@@ -626,6 +626,18 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
|
|
|
626
626
|
* @see https://www.better-auth.com/docs/plugins/passkey
|
|
627
627
|
*/
|
|
628
628
|
passkey: any;
|
|
629
|
+
/**
|
|
630
|
+
* Sign in through a social provider the API configured (`betterAuth.socialProviders` in
|
|
631
|
+
* nest-server). No password is involved, so the parameters go through as they are,
|
|
632
|
+
* `additionalParams` included (`{ prompt: 'none' }` asks the provider for a silent sign-in).
|
|
633
|
+
*
|
|
634
|
+
* Without `idToken` Better-Auth answers with the provider's authorization URL and its
|
|
635
|
+
* client navigates there. With `idToken` it answers `{ token, user }` at once; that token
|
|
636
|
+
* is the session token, removed here like in the 2FA answers, see
|
|
637
|
+
* {@link withoutSessionToken}.
|
|
638
|
+
* @see https://www.better-auth.com/docs/authentication/social-sign-in
|
|
639
|
+
*/
|
|
640
|
+
social: (params: LtSocialSignInParams, options?: unknown) => Promise<any>;
|
|
629
641
|
};
|
|
630
642
|
signOut: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
631
643
|
callbackURL?: string | undefined;
|
|
@@ -188,7 +188,19 @@ export function createLtAuthClient(config = {}) {
|
|
|
188
188
|
* Sign in with passkey (pass through to base client - provided by passkeyClient plugin)
|
|
189
189
|
* @see https://www.better-auth.com/docs/plugins/passkey
|
|
190
190
|
*/
|
|
191
|
-
passkey: baseClient.signIn.passkey
|
|
191
|
+
passkey: baseClient.signIn.passkey,
|
|
192
|
+
/**
|
|
193
|
+
* Sign in through a social provider the API configured (`betterAuth.socialProviders` in
|
|
194
|
+
* nest-server). No password is involved, so the parameters go through as they are,
|
|
195
|
+
* `additionalParams` included (`{ prompt: 'none' }` asks the provider for a silent sign-in).
|
|
196
|
+
*
|
|
197
|
+
* Without `idToken` Better-Auth answers with the provider's authorization URL and its
|
|
198
|
+
* client navigates there. With `idToken` it answers `{ token, user }` at once; that token
|
|
199
|
+
* is the session token, removed here like in the 2FA answers, see
|
|
200
|
+
* {@link withoutSessionToken}.
|
|
201
|
+
* @see https://www.better-auth.com/docs/authentication/social-sign-in
|
|
202
|
+
*/
|
|
203
|
+
social: async (params, options) => withoutSessionToken(await baseClient.signIn.social(params, options))
|
|
192
204
|
},
|
|
193
205
|
// Explicitly pass through signOut (not captured by spread operator)
|
|
194
206
|
signOut: baseClient.signOut,
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The state is persisted in cookies for SSR compatibility.
|
|
13
13
|
*/
|
|
14
|
-
import type { LtAuthMode, LtAuthState } from '../types/index.js';
|
|
14
|
+
import type { LtAuthMode, LtAuthState, LtUserInput } from '../types/index.js';
|
|
15
15
|
/** Default name of the auth-state cookie. Used when the module config has not been resolved yet. */
|
|
16
16
|
export declare const LT_AUTH_STATE_COOKIE_DEFAULT = "lt-auth-state";
|
|
17
17
|
/** Default name of the JWT-token cookie. Used when the module config has not been resolved yet. */
|
|
@@ -262,6 +262,26 @@ export declare function resolveLtPublicApiBaseUrl(): {
|
|
|
262
262
|
baseUrl: string;
|
|
263
263
|
missing: boolean;
|
|
264
264
|
};
|
|
265
|
+
/**
|
|
266
|
+
* The auth state as it is stored: in the `lt-auth-state` cookie, in the `useCookie` ref Nuxt
|
|
267
|
+
* serialises into that cookie (also during SSR), and therefore in `useLtAuth().user`. Every writer
|
|
268
|
+
* of the auth state goes through this function, so they all store the same thing.
|
|
269
|
+
*
|
|
270
|
+
* - `image: null` (Better-Auth's "no picture") becomes `undefined`: readers have one empty case.
|
|
271
|
+
* - An inline image (a `data:` URL) is left out, whatever its size. Better-Auth's Microsoft provider
|
|
272
|
+
* stores the profile photo as one unless the API sets `disableProfilePhoto`, and a few KB of it
|
|
273
|
+
* push the cookie past the browser's limit of 4096 bytes. The browser drops such a cookie without
|
|
274
|
+
* an error, and the next page load finds a signed-in user signed out. An app that shows the photo
|
|
275
|
+
* reads it from the session answer (`GET <basePath>/get-session`).
|
|
276
|
+
* - An `http(s)` URL or a path stays as it is, and so does every other field.
|
|
277
|
+
*
|
|
278
|
+
* INTERNAL: used by `useLtAuth()` and {@link setLtAuthMode}. Not part of the public API (absent
|
|
279
|
+
* from the barrels and auto-imports).
|
|
280
|
+
*/
|
|
281
|
+
export declare function toLtStoredAuthState(state: {
|
|
282
|
+
authMode: LtAuthMode;
|
|
283
|
+
user: LtUserInput | null;
|
|
284
|
+
}): LtAuthState;
|
|
265
285
|
/**
|
|
266
286
|
* Get the current auth mode from cookie
|
|
267
287
|
*/
|
|
@@ -329,7 +349,39 @@ export declare function setLtAuthMode(mode: LtAuthMode): void;
|
|
|
329
349
|
*/
|
|
330
350
|
export declare function getLtApiBase(basePath?: string): string;
|
|
331
351
|
/**
|
|
332
|
-
* `GET <auth>/
|
|
352
|
+
* Learn from a `GET <auth>/features` request whether the API hands out JWTs at all (its `jwt` flag).
|
|
353
|
+
*
|
|
354
|
+
* nest-server with `betterAuth.jwt: false` reports `jwt: false`, and its `/token` answers 404. Once
|
|
355
|
+
* the API said so, {@link requestLtJwt} asks no more, so a cookie-only API sees no `/token` request
|
|
356
|
+
* after a sign-in, a session check or a 401. An answer without the flag (an older API) or a failed
|
|
357
|
+
* request changes nothing: the JWT is fetched as before, and a failed request keeps what an
|
|
358
|
+
* earlier answer said.
|
|
359
|
+
*
|
|
360
|
+
* INTERNAL — called by `useLtAuth().fetchFeatures()` with its request. Not part of the public API.
|
|
361
|
+
*/
|
|
362
|
+
export declare function noteLtJwtServedBy(featuresRequest: Promise<unknown>): void;
|
|
363
|
+
/**
|
|
364
|
+
* Learn the `jwt` flag from features an SSR render already fetched.
|
|
365
|
+
*
|
|
366
|
+
* A page that awaits `fetchFeatures()` on the server (nuxt-base-starter's register page, against a
|
|
367
|
+
* hydration mismatch) sends them in the payload, and the client then fetches none of its own: without
|
|
368
|
+
* this, a cookie-only API got `/token` requests in that tab after all. Taken only while nothing in
|
|
369
|
+
* this tab was noted yet, so a second `useLtAuth()` call never replaces a features request still in
|
|
370
|
+
* flight, and a later live answer wins.
|
|
371
|
+
*
|
|
372
|
+
* INTERNAL — called by `useLtAuth()` on the client. Not part of the public API.
|
|
373
|
+
*/
|
|
374
|
+
export declare function noteLtJwtServedByPayload(features: Record<string, unknown>): void;
|
|
375
|
+
/**
|
|
376
|
+
* Forget what any features request said about JWT.
|
|
377
|
+
*
|
|
378
|
+
* INTERNAL — test-only. Module-scope state survives every test in a file that does not call
|
|
379
|
+
* `vi.resetModules()`. Production code must never call this.
|
|
380
|
+
*/
|
|
381
|
+
export declare function resetLtJwtServedState(): void;
|
|
382
|
+
/**
|
|
383
|
+
* `GET <auth>/token` with the session cookie: a fresh JWT, or `null` (refused, not JWT-shaped,
|
|
384
|
+
* offline, or an API whose `/features` said `jwt: false`, see {@link noteLtJwtServedBy}).
|
|
333
385
|
*
|
|
334
386
|
* INTERNAL — the one place a JWT is fetched: {@link attemptLtJwtSwitch}, the 401 recovery of
|
|
335
387
|
* {@link createLtAuthFetch} and `useLtAuth().switchToJwtMode()` all go through it. Not part of the
|
|
@@ -147,6 +147,17 @@ export function resolveLtPublicApiBaseUrl() {
|
|
|
147
147
|
const publicUrl = pub.apiUrl || pub.ltExtensions?.auth?.baseURL || "";
|
|
148
148
|
return { baseUrl: stripTrailingSlashes(publicUrl), missing: !publicUrl };
|
|
149
149
|
}
|
|
150
|
+
function isLtInlineImage(value) {
|
|
151
|
+
return typeof value === "string" && /^\s*data:/i.test(value);
|
|
152
|
+
}
|
|
153
|
+
export function toLtStoredAuthState(state) {
|
|
154
|
+
const { user } = state;
|
|
155
|
+
if (user === null || typeof user !== "object") {
|
|
156
|
+
return state;
|
|
157
|
+
}
|
|
158
|
+
const image = user.image ?? void 0;
|
|
159
|
+
return { ...state, user: { ...user, image: isLtInlineImage(image) ? void 0 : image } };
|
|
160
|
+
}
|
|
150
161
|
export function getLtAuthMode() {
|
|
151
162
|
if (import.meta.server) return "cookie";
|
|
152
163
|
return resolveLtAuthState(document.cookie)?.authMode || "cookie";
|
|
@@ -223,7 +234,7 @@ export function setLtAuthMode(mode) {
|
|
|
223
234
|
try {
|
|
224
235
|
const { state: stateCookieName } = getLtAuthCookieNames();
|
|
225
236
|
const existing = resolveLtAuthState(document.cookie, stateCookieName);
|
|
226
|
-
const state = { ...existing ?? { user: null }, authMode: mode };
|
|
237
|
+
const state = toLtStoredAuthState({ ...existing ?? { user: null }, authMode: mode });
|
|
227
238
|
const maxAge = 60 * 60 * 24 * 7;
|
|
228
239
|
const secure = globalThis.location?.protocol === "https:" ? "; secure" : "";
|
|
229
240
|
document.cookie = `${stateCookieName}=${encodeURIComponent(JSON.stringify(state))}; path=/; max-age=${maxAge}; samesite=lax${secure}`;
|
|
@@ -240,7 +251,32 @@ export function getLtApiBase(basePath) {
|
|
|
240
251
|
}
|
|
241
252
|
return buildLtApiUrl(basePath || "/iam");
|
|
242
253
|
}
|
|
254
|
+
let ltJwtServed;
|
|
255
|
+
export function noteLtJwtServedBy(featuresRequest) {
|
|
256
|
+
if (!import.meta.client) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const before = ltJwtServed;
|
|
260
|
+
ltJwtServed = featuresRequest.then(
|
|
261
|
+
(features) => {
|
|
262
|
+
const jwt = features?.jwt;
|
|
263
|
+
return typeof jwt === "boolean" ? jwt : void 0;
|
|
264
|
+
},
|
|
265
|
+
() => before
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
export function noteLtJwtServedByPayload(features) {
|
|
269
|
+
if (import.meta.client && !ltJwtServed) {
|
|
270
|
+
noteLtJwtServedBy(Promise.resolve(features));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
export function resetLtJwtServedState() {
|
|
274
|
+
ltJwtServed = void 0;
|
|
275
|
+
}
|
|
243
276
|
export async function requestLtJwt(basePath) {
|
|
277
|
+
if (import.meta.client && ltJwtServed && await ltJwtServed === false) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
244
280
|
try {
|
|
245
281
|
const response = await fetch(`${getLtApiBase(basePath)}/token`, {
|
|
246
282
|
credentials: "include",
|
|
@@ -15,6 +15,6 @@
|
|
|
15
15
|
* with the login out of reach. So nothing is redirected; the setup page stays reachable and shows
|
|
16
16
|
* its notice there (`useSystemSetup().httpInitEnabled === false`).
|
|
17
17
|
*/
|
|
18
|
-
import type { RouteMiddleware } from '
|
|
18
|
+
import type { RouteMiddleware } from 'nuxt/app';
|
|
19
19
|
declare const _default: RouteMiddleware;
|
|
20
20
|
export default _default;
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
* Note: This is a client-only plugin (.client.ts) since auth state
|
|
17
17
|
* management only makes sense in the browser context.
|
|
18
18
|
*/
|
|
19
|
-
import type { ObjectPlugin, Plugin } from '
|
|
19
|
+
import type { ObjectPlugin, Plugin } from 'nuxt/app';
|
|
20
20
|
declare const _default: Plugin & ObjectPlugin;
|
|
21
21
|
export default _default;
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* did (a hydration mismatch). After the mount, hydration has already seen the server's text.
|
|
15
15
|
* How a project translates messages during SSR: README, "Error Translation".
|
|
16
16
|
*/
|
|
17
|
-
import type { ObjectPlugin, Plugin } from '
|
|
17
|
+
import type { ObjectPlugin, Plugin } from 'nuxt/app';
|
|
18
18
|
declare const _default: Plugin & ObjectPlugin;
|
|
19
19
|
export default _default;
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
*
|
|
67
67
|
* Default on; opt out with `ltExtensions.formLabelAssociation.enabled: false`.
|
|
68
68
|
*/
|
|
69
|
-
import type { ObjectPlugin, Plugin } from '
|
|
69
|
+
import type { ObjectPlugin, Plugin } from 'nuxt/app';
|
|
70
70
|
/**
|
|
71
71
|
* Re-point every dangling field label at the control in its own field.
|
|
72
72
|
*
|
|
@@ -12,6 +12,6 @@
|
|
|
12
12
|
* `warnMissingLtApiUrl()` is one-shot, so the warning still appears exactly once
|
|
13
13
|
* per process — and `buildLtApiUrl()` shares the same key, so it never repeats.
|
|
14
14
|
*/
|
|
15
|
-
import type { ObjectPlugin, Plugin } from '
|
|
15
|
+
import type { ObjectPlugin, Plugin } from 'nuxt/app';
|
|
16
16
|
declare const _default: ObjectPlugin & Plugin;
|
|
17
17
|
export default _default;
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
* browsers do not raise the on-screen keyboard for it. Preserving the entry avoids all of
|
|
52
52
|
* that, because the field is never anything other than a normal, editable field.
|
|
53
53
|
*/
|
|
54
|
-
import type { ObjectPlugin, Plugin } from '
|
|
54
|
+
import type { ObjectPlugin, Plugin } from 'nuxt/app';
|
|
55
55
|
type EditableField = HTMLInputElement | HTMLTextAreaElement;
|
|
56
56
|
/**
|
|
57
57
|
* Collect fields the user edited before hydration.
|
|
@@ -13,6 +13,11 @@ export interface LtUser {
|
|
|
13
13
|
/**
|
|
14
14
|
* Stored as `string | undefined`, never `null` — see {@link LtUserInput}, which is what
|
|
15
15
|
* `setUser` accepts. Reading code therefore has one empty case to handle, not two.
|
|
16
|
+
*
|
|
17
|
+
* An inline image (a `data:` URL, as Better-Auth's Microsoft provider stores the profile photo)
|
|
18
|
+
* is never stored, because it would push the `lt-auth-state` cookie past the browser's limit, so
|
|
19
|
+
* it reads as `undefined` here. Read the photo from the session answer
|
|
20
|
+
* (`GET <basePath>/get-session`) where an avatar needs it; an `http(s)` URL or a path is kept.
|
|
16
21
|
*/
|
|
17
22
|
image?: string;
|
|
18
23
|
name?: string;
|
|
@@ -48,6 +53,8 @@ export interface LtUser {
|
|
|
48
53
|
* `setUser` normalises `null` to `undefined` on the way in, so the stored user and every
|
|
49
54
|
* reader keep the single empty case. Widening `LtUser.image` itself would have done the
|
|
50
55
|
* opposite: pushed a second empty value onto everyone who only READS it.
|
|
56
|
+
*
|
|
57
|
+
* An `image` that is a `data:` URL is stored as `undefined` as well (see {@link LtUser.image}).
|
|
51
58
|
*/
|
|
52
59
|
export type LtUserInput = Omit<LtUser, 'image'> & {
|
|
53
60
|
image?: null | string;
|
|
@@ -151,6 +158,54 @@ type NoStrayCredential<T, Own extends string> = Omit<{
|
|
|
151
158
|
newPassword?: never;
|
|
152
159
|
password?: never;
|
|
153
160
|
}, Own> & T;
|
|
161
|
+
/**
|
|
162
|
+
* Parameters of a sign-in through a social provider (`POST <basePath>/sign-in/social`), as
|
|
163
|
+
* Better-Auth takes them. `provider` is the key the API configured under
|
|
164
|
+
* `betterAuth.socialProviders` (`'google'`, `'github'`, `'microsoft'`, …); `/iam/features` lists
|
|
165
|
+
* the enabled ones as `socialProviders`.
|
|
166
|
+
*
|
|
167
|
+
* Without `idToken` the answer is the provider's authorization URL and the browser goes there.
|
|
168
|
+
* It comes back to `callbackURL` signed in, or to `errorCallbackURL` with `?error=`. Both must be
|
|
169
|
+
* absolute URLs of an origin the API trusts (`trustedOrigins`): Better-Auth resolves a relative
|
|
170
|
+
* value against the API.
|
|
171
|
+
*/
|
|
172
|
+
export interface LtSocialSignInParams {
|
|
173
|
+
/** Data Better-Auth carries through the OAuth flow and hands to its hooks. */
|
|
174
|
+
additionalData?: Record<string, unknown>;
|
|
175
|
+
/**
|
|
176
|
+
* Extra query parameters for the provider's authorization URL, for this request only.
|
|
177
|
+
* `{ prompt: 'none' }` asks for a silent sign-in: the provider answers without showing
|
|
178
|
+
* anything, with the session if the user has one there and with an error otherwise
|
|
179
|
+
* (`errorCallbackURL`). `{ prompt: 'select_account' }` lets the user pick another account.
|
|
180
|
+
*/
|
|
181
|
+
additionalParams?: Record<string, string>;
|
|
182
|
+
/** Where the browser lands after a successful sign-in. */
|
|
183
|
+
callbackURL?: string;
|
|
184
|
+
/** Answer with the authorization URL without navigating to it. */
|
|
185
|
+
disableRedirect?: boolean;
|
|
186
|
+
/** Where the browser lands when the provider or Better-Auth refuses; the reason is in `?error=`. */
|
|
187
|
+
errorCallbackURL?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Sign in with an ID token the provider already issued for this application, without a
|
|
190
|
+
* redirect: an app inside a host that knows the user (Microsoft Teams, a native shell).
|
|
191
|
+
*/
|
|
192
|
+
idToken?: {
|
|
193
|
+
accessToken?: string;
|
|
194
|
+
nonce?: string;
|
|
195
|
+
refreshToken?: string;
|
|
196
|
+
token: string;
|
|
197
|
+
};
|
|
198
|
+
/** The account to suggest to the provider (an e-mail address), which skips its account picker. */
|
|
199
|
+
loginHint?: string;
|
|
200
|
+
/** Where the browser lands after a sign-in that created the account. */
|
|
201
|
+
newUserCallbackURL?: string;
|
|
202
|
+
/** The provider's key on the API. */
|
|
203
|
+
provider: string;
|
|
204
|
+
/** Ask for a new account where the provider is configured with `disableImplicitSignUp`. */
|
|
205
|
+
requestSignUp?: boolean;
|
|
206
|
+
/** Scopes to request on top of the ones the API configured. */
|
|
207
|
+
scopes?: string[];
|
|
208
|
+
}
|
|
154
209
|
export interface UseLtAuthReturn {
|
|
155
210
|
authMode: ComputedRef<LtAuthMode>;
|
|
156
211
|
isAuthenticated: ComputedRef<boolean>;
|
|
@@ -280,7 +335,8 @@ export interface UseLtAuthReturn {
|
|
|
280
335
|
*
|
|
281
336
|
* Accepts {@link LtUserInput}, so `getSession().data.user` can be handed over unchanged —
|
|
282
337
|
* Better Auth writes "no picture" as `image: null`, which this normalises to `undefined`
|
|
283
|
-
* before storing. Readers of {@link LtUser} keep a single empty case.
|
|
338
|
+
* before storing. Readers of {@link LtUser} keep a single empty case. An inline `data:` image
|
|
339
|
+
* is not stored either (see {@link LtUser.image}).
|
|
284
340
|
*/
|
|
285
341
|
setUser: (userData: LtUserInput | null, mode?: LtAuthMode) => void;
|
|
286
342
|
signIn: {
|
|
@@ -290,6 +346,12 @@ export interface UseLtAuthReturn {
|
|
|
290
346
|
rememberMe?: boolean;
|
|
291
347
|
}>(params: NoStrayCredential<T, 'password'>, options?: unknown) => Promise<unknown>;
|
|
292
348
|
passkey?: (options?: unknown) => Promise<unknown>;
|
|
349
|
+
/**
|
|
350
|
+
* Sign-in through a social provider the API configured (see {@link LtSocialSignInParams}).
|
|
351
|
+
* A redirect answer leaves the page; an ID-token answer signs the user in at once, on the
|
|
352
|
+
* cookie session, with the JWT fetched from `/iam/token`.
|
|
353
|
+
*/
|
|
354
|
+
social: (params: LtSocialSignInParams, options?: unknown) => Promise<unknown>;
|
|
293
355
|
};
|
|
294
356
|
signOut: (options?: unknown) => Promise<unknown>;
|
|
295
357
|
signUp: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, LtUser, LtUserInput, UseLtAuthReturn } from './auth.js';
|
|
1
|
+
export type { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, LtSocialSignInParams, LtUser, LtUserInput, UseLtAuthReturn, } from './auth.js';
|
|
2
2
|
export type { LtFileInfo, LtUploadItem, LtUploadOptions, LtUploadProgress, LtUploadStatus, UseLtFileReturn, UseLtTusUploadReturn } from './upload.js';
|
|
3
3
|
export type { LtAiModuleOptions, LtAuthCookieNamesOptions, LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtFormLabelAssociationOptions, LtI18nModuleOptions, LtPreHydrationInputOptions, LtSecurityTxtOptions, LtSystemSetupModuleOptions, LtTusModuleOptions, } from './module.js';
|
|
4
4
|
export type { LtErrorTranslationResponse, LtParsedError, UseLtErrorTranslationReturn } from './error.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nuxt-extensions",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -111,27 +111,27 @@
|
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
113
|
"@better-auth/passkey": "1.7.19",
|
|
114
|
-
"@nuxt/module-builder": "1.0.
|
|
114
|
+
"@nuxt/module-builder": "1.0.4",
|
|
115
115
|
"@nuxt/schema": "4.6.4",
|
|
116
|
-
"@nuxt/ui": "4.12.
|
|
117
|
-
"@playwright/test": "1.65.
|
|
116
|
+
"@nuxt/ui": "4.12.2",
|
|
117
|
+
"@playwright/test": "1.65.1",
|
|
118
118
|
"@types/node": "26.6.6",
|
|
119
|
-
"@vitest/coverage-v8": "5.1.
|
|
120
|
-
"@vue/server-renderer": "3.5.
|
|
119
|
+
"@vitest/coverage-v8": "5.1.1",
|
|
120
|
+
"@vue/server-renderer": "3.5.46",
|
|
121
121
|
"better-auth": "1.7.19",
|
|
122
122
|
"cross-spawn": "7.0.6",
|
|
123
123
|
"fake-indexeddb": "6.2.8",
|
|
124
124
|
"happy-dom": "21.0.4",
|
|
125
125
|
"nuxt": "4.6.4",
|
|
126
|
-
"oxfmt": "0.
|
|
127
|
-
"oxlint": "1.
|
|
128
|
-
"oxlint-tsgolint": "7.0.
|
|
126
|
+
"oxfmt": "0.79.0",
|
|
127
|
+
"oxlint": "1.94.0",
|
|
128
|
+
"oxlint-tsgolint": "7.0.2008",
|
|
129
129
|
"reka-ui": "2.11.0",
|
|
130
130
|
"semver": "7.8.6",
|
|
131
131
|
"tailwindcss": "4.3.5",
|
|
132
132
|
"tus-js-client": "4.3.1",
|
|
133
133
|
"typescript": "5.9.3",
|
|
134
|
-
"vitest": "5.1.
|
|
134
|
+
"vitest": "5.1.1",
|
|
135
135
|
"vue-tsc": "3.3.14"
|
|
136
136
|
},
|
|
137
137
|
"keywords": [
|