@lenne.tech/nuxt-extensions 4.0.1 → 4.0.3
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 +66 -5
- package/README.md +89 -3
- package/dist/module.d.mts +1 -1
- package/dist/module.json +2 -2
- package/dist/module.mjs +4 -1
- package/dist/runtime/composables/auth/use-lt-auth.js +22 -6
- 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 +42 -6
- package/dist/runtime/lib/auth-state.js +12 -1
- package/dist/runtime/lib/index.d.ts +1 -1
- package/dist/runtime/lib/index.js +1 -0
- 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 +14 -14
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) |
|
|
@@ -106,6 +106,21 @@ export default defineNuxtConfig({
|
|
|
106
106
|
|
|
107
107
|
The API base URL is resolved at runtime from `NUXT_PUBLIC_API_URL` (client + SSR fallback) and the optional `NUXT_API_URL` (SSR-only, e.g. for internal cluster addresses). `NUXT_API_URL` is never promoted into the public bundle.
|
|
108
108
|
|
|
109
|
+
**URLs that end up in HTML use `buildLtPublicApiUrl()`, never `buildLtApiUrl()`.** During SSR
|
|
110
|
+
`buildLtApiUrl()` and `getLtApiBase()` return `NUXT_API_URL`: they build the URLs the server
|
|
111
|
+
requests itself. Rendered into `src`, `href`, `srcset`, a CSS `url()` or a `useState` value, that
|
|
112
|
+
internal address (`http://api:3000`) reaches every visitor, and images and downloads break in
|
|
113
|
+
production only, where it differs from the public one. A project with a vendored core did exactly
|
|
114
|
+
that in November 2026. `buildLtPublicApiUrl()` (auto-imported, also in `/lib`) and the file links
|
|
115
|
+
of `useLtFile()` use the browser's address during SSR too.
|
|
116
|
+
|
|
117
|
+
- **Nothing this module renders or stores in state may use the request URL.** Error texts count:
|
|
118
|
+
Node's fetch names the request URL in some errors, so `useLtAiStatus()` stores fixed texts, never
|
|
119
|
+
`error.message`.
|
|
120
|
+
- **Guards:** `test/ssr-api-url-in-html.test.ts` renders in the server scope with an internal and a
|
|
121
|
+
public address (part of `check`), and `check:consumer` renders a page on the built Nitro server
|
|
122
|
+
with `NUXT_API_URL` set (part of `release`). Both fail as soon as the internal host is in the HTML.
|
|
123
|
+
|
|
109
124
|
## Authentication (Better Auth)
|
|
110
125
|
|
|
111
126
|
- SSR-safe session management via `useLtAuth()`
|
|
@@ -113,6 +128,7 @@ The API base URL is resolved at runtime from `NUXT_PUBLIC_API_URL` (client + SSR
|
|
|
113
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
|
|
114
129
|
- Passkey (WebAuthn) support via `@better-auth/passkey` peer dependency
|
|
115
130
|
- 2FA (TOTP) support built-in
|
|
131
|
+
- Sign-in through a social provider the API configured (`signIn.social`, see below)
|
|
116
132
|
|
|
117
133
|
### Auth Flow
|
|
118
134
|
|
|
@@ -264,9 +280,9 @@ unchanged. That token is the session token, the value the API keeps in the httpO
|
|
|
264
280
|
- **`setUser(user, 'jwt')` without a stored JWT falls back to `'cookie'`** and fetches the JWT.
|
|
265
281
|
Without that fallback, the refusal above would turn a hand-written 2FA page into a sign-in that
|
|
266
282
|
sends no credentials at all.
|
|
267
|
-
- **`useLtAuthClient().twoFactor.verify*`
|
|
268
|
-
`authenticateWithPasskey()` returns no `session`. Keep
|
|
269
|
-
receives the session token cannot store it.
|
|
283
|
+
- **`useLtAuthClient().twoFactor.verify*` and `signIn.social` strip a non-JWT `token` from the
|
|
284
|
+
answer**, and `authenticateWithPasskey()` returns no `session`. Keep all three: application code
|
|
285
|
+
that never receives the session token cannot store it.
|
|
270
286
|
|
|
271
287
|
### How Auth Cookies Work:
|
|
272
288
|
1. `setUser()` writes the cookie via both `useCookie().value` (for SSR sync) and `document.cookie` (for immediate availability)
|
|
@@ -312,6 +328,51 @@ export default defineNuxtRouteMiddleware((to) => {
|
|
|
312
328
|
});
|
|
313
329
|
```
|
|
314
330
|
|
|
331
|
+
## Social Sign-In (`signIn.social`, since 4.0.3)
|
|
332
|
+
|
|
333
|
+
`useLtAuth().signIn.social(params)` signs in through a provider the API configured
|
|
334
|
+
(`betterAuth.socialProviders` in nest-server; first use: Microsoft Entra ID as single sign-on).
|
|
335
|
+
`GET /iam/features` lists the enabled providers as `socialProviders`, which `useLtAuth().features`
|
|
336
|
+
holds. `useLtAuthClient().signIn.social` is the same call without the auth state. Parameters:
|
|
337
|
+
`LtSocialSignInParams` in `runtime/types/auth.ts`.
|
|
338
|
+
|
|
339
|
+
- **Redirect shape (no `idToken`): the page is left.** The answer is the provider's authorization
|
|
340
|
+
URL and Better Auth's client navigates there; nothing is stored. The API's callback sets the
|
|
341
|
+
session cookie and redirects to `callbackURL`, where the user arrives through `validateSession()`.
|
|
342
|
+
- **ID-token shape: signed in at once.** For an app inside a host that already knows the user
|
|
343
|
+
(Microsoft Teams, a native shell). The answer is `{ token, user }`; the wrapper strips the session
|
|
344
|
+
token, and `completeForwardedSignIn()` signs the user in on the cookie session and fetches the
|
|
345
|
+
JWT from `/iam/token`, exactly as after 2FA. `withoutSessionToken` strips only `result.data`, as
|
|
346
|
+
for 2FA: with `throw: true` (as `options` or in `fetchOptions`) the body comes back with the
|
|
347
|
+
token, and a caller's `onSuccess` hook sees the answer before the token is removed.
|
|
348
|
+
- **Silent attempt: `additionalParams: { prompt: 'none' }`.** The provider answers without showing
|
|
349
|
+
anything, and the way back without a provider session is `errorCallbackURL` with
|
|
350
|
+
`?error=login_required` (or `interaction_required`). A page that starts the attempt on load must
|
|
351
|
+
remember per tab that it tried, and must not try after an explicit sign-out; otherwise it loops
|
|
352
|
+
or signs the user straight back in. nuxt-base-starter's login page shows the pattern.
|
|
353
|
+
- **`?error=` is a code; map it, never render the query.** The provider's own codes
|
|
354
|
+
(`access_denied`, `consent_required`, …) and Better Auth's (`signup_disabled`, …) arrive there,
|
|
355
|
+
next to an `error_description` anybody can write into a link.
|
|
356
|
+
- **`callbackURL` / `errorCallbackURL` must be absolute URLs of a trusted origin, never user
|
|
357
|
+
input.** Same reasoning as `redirectTo` below: Better Auth resolves a relative value against the
|
|
358
|
+
API origin, and `trustedOrigins` is the only check on the result. Build both from the app's own
|
|
359
|
+
origin and a fixed path (`appUrl()` in the starters); a deep link goes into their query only after
|
|
360
|
+
`safeRedirectTarget()`.
|
|
361
|
+
- **Nothing is hashed.** No credential travels, so the parameters go through unchanged; the
|
|
362
|
+
wrapper changes only the answer. `test/auth-client-social-sign-in.test.ts`,
|
|
363
|
+
`test/social-sign-in-session.test.ts` and the `signIn.social` case in
|
|
364
|
+
`test/better-auth-contract.test.ts` (real better-auth client, stubbed `fetch`) hold this.
|
|
365
|
+
|
|
366
|
+
**An inline image never reaches the auth state.** Better Auth's Microsoft provider stores the
|
|
367
|
+
profile photo in `user.image` as a `data:` URL. In `lt-auth-state` a few KB of it push the cookie
|
|
368
|
+
past the browser's 4096 bytes, the browser drops it without an error, and the next page load reads
|
|
369
|
+
as a logout (with a silent sign-in on the login page: a loop through app, API and provider). Every
|
|
370
|
+
writer of the auth state goes through `toLtStoredAuthState()` in `lib/auth-state.ts`, which leaves a
|
|
371
|
+
`data:` image out at any size and keeps an `http(s)` URL or a path; `user.value.image` is then
|
|
372
|
+
`undefined`, and an app reads the photo from `GET <basePath>/get-session`. An API that does not need
|
|
373
|
+
the photo sets `disableProfilePhoto: true` on the Microsoft provider. A new writer of the auth state
|
|
374
|
+
uses the same function. `test/auth-state-inline-image.test.ts` emulates the browser's limit.
|
|
375
|
+
|
|
315
376
|
## Password Handling: Reset, Change, and Client-Side Hashing
|
|
316
377
|
|
|
317
378
|
**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)
|
|
@@ -147,6 +147,12 @@ All requests go to `/api/{path}` — the Vite dev proxy forwards them to the bac
|
|
|
147
147
|
|
|
148
148
|
> **Security:** `NUXT_API_URL` is never exposed to the client bundle. It stays in `runtimeConfig.apiUrl` (server only). This is important when using internal network addresses like `http://api.svc.cluster.local`.
|
|
149
149
|
|
|
150
|
+
> **URLs that end up in HTML: `buildLtPublicApiUrl()`, never `buildLtApiUrl()`.** During SSR `buildLtApiUrl()` (and `getLtApiBase()`) return `NUXT_API_URL`, because they build the URLs the server requests itself. Rendered into a `src`, `href`, `srcset`, a CSS `url()` or a `useState` value, that internal address reaches every visitor's HTML, and images and downloads break in production only, where it differs from the public one. `buildLtPublicApiUrl()` (auto-imported, also exported from `/lib`) and the file links of `useLtFile()` use the browser's address during SSR too:
|
|
151
|
+
>
|
|
152
|
+
> ```vue
|
|
153
|
+
> <img :src="buildLtPublicApiUrl(`/users/${user.id}/avatar`)" alt="">
|
|
154
|
+
> ```
|
|
155
|
+
|
|
150
156
|
### Deployment Scenarios
|
|
151
157
|
|
|
152
158
|
**Local development** — Frontend and backend on different ports, proxy ensures same-origin cookies:
|
|
@@ -542,6 +548,86 @@ JWT from `/iam/token`.
|
|
|
542
548
|
session token.**
|
|
543
549
|
- **`authenticateWithPasskey()` returns no `session`.**
|
|
544
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
|
+
|
|
545
631
|
#### Authenticated requests: `fetchWithAuth` and `ltAuthFetch`
|
|
546
632
|
|
|
547
633
|
`useLtAuth().fetchWithAuth` and `ltAuthFetch` (from `/lib`, also used by the Better-Auth client,
|
|
@@ -1201,8 +1287,8 @@ The package works **with or without** `@nuxtjs/i18n`:
|
|
|
1201
1287
|
|
|
1202
1288
|
| Composable | Description |
|
|
1203
1289
|
|------------|-------------|
|
|
1204
|
-
| `useLtAuth()` | Better-Auth integration with session, passkey, 2FA, password change + reset |
|
|
1205
|
-
| `useLtAuthClient()` | Direct access to the Better-Auth client singleton (`twoFactor.*`, `admin.*`, `passkey`) |
|
|
1290
|
+
| `useLtAuth()` | Better-Auth integration with session, passkey, 2FA, social sign-in, password change + reset |
|
|
1291
|
+
| `useLtAuthClient()` | Direct access to the Better-Auth client singleton (`twoFactor.*`, `admin.*`, `passkey`, `signIn.social`) |
|
|
1206
1292
|
| `useLtErrorTranslation()` | Translate backend error codes to user-friendly messages |
|
|
1207
1293
|
| `useLtTusUpload()` | TUS protocol file uploads with pause/resume |
|
|
1208
1294
|
| `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.3";
|
|
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.3";
|
|
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";
|
|
@@ -201,6 +201,9 @@ const module$1 = defineNuxtModule({
|
|
|
201
201
|
{ name: "getLtApiBase", from: resolve("./runtime/lib/auth-state") },
|
|
202
202
|
{ name: "getLtAuthCookieNames", from: resolve("./runtime/lib/auth-state") },
|
|
203
203
|
{ name: "buildLtApiUrl", from: resolve("./runtime/lib/auth-state") },
|
|
204
|
+
// The URL for HTML (`src`, `href`): buildLtApiUrl is for requests and renders the server-only
|
|
205
|
+
// NUXT_API_URL during SSR. Auto-imported so the right one is as close at hand as the wrong one.
|
|
206
|
+
{ name: "buildLtPublicApiUrl", from: resolve("./runtime/lib/auth-state") },
|
|
204
207
|
{ name: "isLocalDevApiProxy", from: resolve("./runtime/lib/auth-state") },
|
|
205
208
|
{ name: "attemptLtJwtSwitch", from: resolve("./runtime/lib/auth-state") },
|
|
206
209
|
{ name: "isLtAuthenticated", from: resolve("./runtime/lib/auth-state") },
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
isLtJwtShaped,
|
|
10
10
|
requestLtJwt,
|
|
11
11
|
resolveLtAuthState,
|
|
12
|
+
toLtStoredAuthState,
|
|
12
13
|
warnLtAdminPluginUnserved
|
|
13
14
|
} from "../../lib/auth-state.js";
|
|
14
15
|
import { useLtAuthClient } from "../use-lt-auth-client.js";
|
|
@@ -45,7 +46,7 @@ export function useLtAuth() {
|
|
|
45
46
|
try {
|
|
46
47
|
const resolved = resolveLtAuthState(document.cookie, stateCookieName);
|
|
47
48
|
if (resolved?.user && !authState.value?.user) {
|
|
48
|
-
authState.value = resolved;
|
|
49
|
+
authState.value = toLtStoredAuthState(resolved);
|
|
49
50
|
}
|
|
50
51
|
} catch {
|
|
51
52
|
}
|
|
@@ -99,8 +100,7 @@ export function useLtAuth() {
|
|
|
99
100
|
if (mode !== requestedMode && import.meta.client && userData) {
|
|
100
101
|
void switchToJwtMode();
|
|
101
102
|
}
|
|
102
|
-
const
|
|
103
|
-
const newState = { user: normalised, authMode: mode };
|
|
103
|
+
const newState = toLtStoredAuthState({ user: userData, authMode: mode });
|
|
104
104
|
if (import.meta.client || userData) {
|
|
105
105
|
authState.value = newState;
|
|
106
106
|
}
|
|
@@ -128,7 +128,7 @@ export function useLtAuth() {
|
|
|
128
128
|
jwtToken.value = token;
|
|
129
129
|
}
|
|
130
130
|
if (authState.value && authState.value.authMode !== "jwt") {
|
|
131
|
-
authState.value = { ...authState.value, authMode: "jwt" };
|
|
131
|
+
authState.value = toLtStoredAuthState({ ...authState.value, authMode: "jwt" });
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
async function switchToJwtMode() {
|
|
@@ -245,6 +245,22 @@ export function useLtAuth() {
|
|
|
245
245
|
} finally {
|
|
246
246
|
isLoading.value = false;
|
|
247
247
|
}
|
|
248
|
+
},
|
|
249
|
+
/**
|
|
250
|
+
* Sign in through a social provider the API configured. A redirect answer carries no user and
|
|
251
|
+
* leaves the page: the user arrives with `validateSession()` on the page the provider sends the
|
|
252
|
+
* browser back to. An ID-token answer carries the user and is completed here, see
|
|
253
|
+
* `completeForwardedSignIn`.
|
|
254
|
+
*/
|
|
255
|
+
social: async (params, options) => {
|
|
256
|
+
isLoading.value = true;
|
|
257
|
+
try {
|
|
258
|
+
const result = await authClient.signIn.social(params, options);
|
|
259
|
+
await completeForwardedSignIn(result);
|
|
260
|
+
return result;
|
|
261
|
+
} finally {
|
|
262
|
+
isLoading.value = false;
|
|
263
|
+
}
|
|
248
264
|
}
|
|
249
265
|
};
|
|
250
266
|
const signUp = {
|
|
@@ -475,7 +491,7 @@ export function useLtAuth() {
|
|
|
475
491
|
isLoading.value = false;
|
|
476
492
|
}
|
|
477
493
|
}
|
|
478
|
-
async function
|
|
494
|
+
async function completeForwardedSignIn(result) {
|
|
479
495
|
const answer = result;
|
|
480
496
|
const data = answer?.data;
|
|
481
497
|
if (answer?.error || !data?.user) {
|
|
@@ -493,7 +509,7 @@ export function useLtAuth() {
|
|
|
493
509
|
isLoading.value = true;
|
|
494
510
|
try {
|
|
495
511
|
const result = await authClient.twoFactor[method](params, options);
|
|
496
|
-
await
|
|
512
|
+
await completeForwardedSignIn(result);
|
|
497
513
|
return result;
|
|
498
514
|
} finally {
|
|
499
515
|
isLoading.value = false;
|
|
@@ -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. */
|
|
@@ -186,6 +186,14 @@ export declare function warnMissingLtApiUrl(scope: 'client' | 'server'): void;
|
|
|
186
186
|
/**
|
|
187
187
|
* Build a full API URL for a given path, handling SSR, proxy, and direct modes.
|
|
188
188
|
*
|
|
189
|
+
* **For requests only, never for a URL that ends up in HTML.** During SSR this returns the
|
|
190
|
+
* server-only `NUXT_API_URL`, an internal address such as `http://api:3000`. Anything rendered with
|
|
191
|
+
* it (`src`, `href`, `srcset`, a CSS `url()`, a value in `useState` or another part of the SSR
|
|
192
|
+
* payload) ships that address to every visitor, whose browser cannot reach it: images and
|
|
193
|
+
* downloads break in production only, where the internal address differs from the public one. For
|
|
194
|
+
* links and images use {@link buildLtPublicApiUrl} or `useLtFile()`. This function is for requests
|
|
195
|
+
* the code makes itself (`fetch`, `$fetch`, `ltAuthFetch`).
|
|
196
|
+
*
|
|
189
197
|
* ## Resolution Strategy
|
|
190
198
|
*
|
|
191
199
|
* All environment variables are resolved **at runtime** by Nuxt's built-in
|
|
@@ -225,11 +233,16 @@ export declare function buildLtApiUrl(path: string): string;
|
|
|
225
233
|
/**
|
|
226
234
|
* The URL the browser uses for an API path, built the same way during SSR.
|
|
227
235
|
*
|
|
228
|
-
*
|
|
229
|
-
* `
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
236
|
+
* Use it for every API URL that ends up in HTML: `src`, `href`, `srcset`, avatars, images,
|
|
237
|
+
* downloads, a CSS `url()`, or a value stored in `useState` (the SSR payload is part of the HTML).
|
|
238
|
+
* {@link buildLtApiUrl} would put the server-only `NUXT_API_URL` (an internal cluster address
|
|
239
|
+
* such as `http://api:3000`) into the HTML during SSR, and behind the dev proxy the server and the
|
|
240
|
+
* browser would render different strings, a hydration mismatch. File links of `useLtFile()` use
|
|
241
|
+
* this already. Requests the server makes itself keep using {@link buildLtApiUrl}.
|
|
242
|
+
*
|
|
243
|
+
* ```vue
|
|
244
|
+
* <img :src="buildLtPublicApiUrl(`/users/${user.id}/avatar`)" alt="">
|
|
245
|
+
* ```
|
|
233
246
|
*
|
|
234
247
|
* `/api` + path while the dev proxy is on, otherwise `NUXT_PUBLIC_API_URL` (or `auth.baseURL`) +
|
|
235
248
|
* path; relative (with the one-shot warning) when neither is configured.
|
|
@@ -249,6 +262,26 @@ export declare function resolveLtPublicApiBaseUrl(): {
|
|
|
249
262
|
baseUrl: string;
|
|
250
263
|
missing: boolean;
|
|
251
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;
|
|
252
285
|
/**
|
|
253
286
|
* Get the current auth mode from cookie
|
|
254
287
|
*/
|
|
@@ -309,6 +342,9 @@ export declare function setLtAuthMode(mode: LtAuthMode): void;
|
|
|
309
342
|
* - **Direct mode** (proxy disabled or not set): Returns `{baseURL}{basePath}`
|
|
310
343
|
* (e.g., `https://api.example.com/iam`) for direct backend calls.
|
|
311
344
|
*
|
|
345
|
+
* For requests only: during SSR it holds the server-only `NUXT_API_URL`, so it must never be
|
|
346
|
+
* rendered into HTML (see {@link buildLtApiUrl}).
|
|
347
|
+
*
|
|
312
348
|
* @param basePath - The auth API base path. If not provided, reads from runtime config (default: '/iam')
|
|
313
349
|
*/
|
|
314
350
|
export declare function getLtApiBase(basePath?: string): string;
|
|
@@ -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}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { attemptLtJwtSwitch, clearLtAuthCookies, createLtAuthFetch, getLtApiBase, getLtAuthCookieNames, getLtAuthMode, getLtJwtToken, isLtAuthenticated, isLtJwtShaped, LT_AUTH_STATE_COOKIE_DEFAULT, LT_JWT_TOKEN_COOKIE_DEFAULT, ltAuthFetch, setLtAuthMode, setLtJwtToken, } from './auth-state.js';
|
|
1
|
+
export { attemptLtJwtSwitch, buildLtPublicApiUrl, clearLtAuthCookies, createLtAuthFetch, getLtApiBase, getLtAuthCookieNames, getLtAuthMode, getLtJwtToken, isLtAuthenticated, isLtJwtShaped, LT_AUTH_STATE_COOKIE_DEFAULT, LT_JWT_TOKEN_COOKIE_DEFAULT, ltAuthFetch, setLtAuthMode, setLtJwtToken, } from './auth-state.js';
|
|
2
2
|
export { clearLtAuthPluginRegistry, createLtAuthClient, getOrCreateLtAuthClient, getLtAuthPluginRegistry, registerLtAuthPlugins, resetLtAuthClientSingleton, type LtAuthClient, } from './auth-client.js';
|
|
3
3
|
export { buildLtAiUrl, getLtAiBasePath, ltAiRequest, ltAiResponseError, parseLtAiSseStream } from './ai.js';
|
|
4
4
|
export { buildLtSyncUrl, flushLtSyncBeforeSignOut, getLtSyncBasePath, ltSyncObjectId, ltSyncUuidV7 } from './sync.js';
|
|
@@ -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.3",
|
|
4
4
|
"description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -110,28 +110,28 @@
|
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
|
-
"@better-auth/passkey": "1.7.
|
|
114
|
-
"@nuxt/module-builder": "1.0.
|
|
113
|
+
"@better-auth/passkey": "1.7.19",
|
|
114
|
+
"@nuxt/module-builder": "1.0.4",
|
|
115
115
|
"@nuxt/schema": "4.6.4",
|
|
116
|
-
"@nuxt/ui": "4.12.
|
|
117
|
-
"@playwright/test": "1.
|
|
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.
|
|
121
|
-
"better-auth": "1.7.
|
|
119
|
+
"@vitest/coverage-v8": "5.1.1",
|
|
120
|
+
"@vue/server-renderer": "3.5.45",
|
|
121
|
+
"better-auth": "1.7.19",
|
|
122
122
|
"cross-spawn": "7.0.6",
|
|
123
|
-
"fake-indexeddb": "6.2.
|
|
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.2007",
|
|
129
129
|
"reka-ui": "2.11.0",
|
|
130
130
|
"semver": "7.8.6",
|
|
131
|
-
"tailwindcss": "4.3.
|
|
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": [
|