@lenne.tech/nuxt-extensions 1.16.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.d.mts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/auth/use-lt-auth.js +2 -1
- package/dist/runtime/composables/use-lt-error-translation.js +4 -0
- package/dist/runtime/lib/auth-client.d.ts +120 -649
- package/dist/runtime/lib/auth-client.js +47 -8
- package/dist/runtime/types/auth.d.ts +30 -1
- package/dist/runtime/types/error.d.ts +26 -1
- package/dist/runtime/types/index.d.ts +1 -1
- package/package.json +4 -4
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 = "1.
|
|
6
|
+
declare const version = "1.18.0";
|
|
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
|
@@ -2,7 +2,7 @@ import { defineNuxtModule, createResolver, tryResolveModule, addImports, addComp
|
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
3
|
|
|
4
4
|
const name = "@lenne.tech/nuxt-extensions";
|
|
5
|
-
const version = "1.
|
|
5
|
+
const version = "1.18.0";
|
|
6
6
|
const configKey = "ltExtensions";
|
|
7
7
|
const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
|
|
8
8
|
const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
|
|
@@ -61,7 +61,8 @@ export function useLtAuth() {
|
|
|
61
61
|
const features = useState("lt-auth-features", () => ({}));
|
|
62
62
|
const featuresFetched = useState("lt-auth-features-fetched", () => false);
|
|
63
63
|
function setUser(userData, mode = "cookie") {
|
|
64
|
-
const
|
|
64
|
+
const normalised = userData ? { ...userData, image: userData.image ?? void 0 } : null;
|
|
65
|
+
const newState = { user: normalised, authMode: mode };
|
|
65
66
|
if (import.meta.client || userData) {
|
|
66
67
|
authState.value = newState;
|
|
67
68
|
}
|
|
@@ -59,6 +59,10 @@ export function useLtErrorTranslation() {
|
|
|
59
59
|
return errorOrMessage;
|
|
60
60
|
}
|
|
61
61
|
if (errorOrMessage instanceof Error) {
|
|
62
|
+
const body = errorOrMessage.data;
|
|
63
|
+
if (typeof body?.message === "string" && body.message) {
|
|
64
|
+
return body.message;
|
|
65
|
+
}
|
|
62
66
|
return errorOrMessage.message;
|
|
63
67
|
}
|
|
64
68
|
if (typeof errorOrMessage === "object" && errorOrMessage !== null) {
|
|
@@ -329,6 +329,99 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
|
|
|
329
329
|
listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
330
330
|
atoms: Record<string, import("better-auth/client").WritableAtom<any>>;
|
|
331
331
|
};
|
|
332
|
+
/**
|
|
333
|
+
* Read the current session (`GET /get-session`).
|
|
334
|
+
*
|
|
335
|
+
* Carries no credential, so it is a bare passthrough.
|
|
336
|
+
*/
|
|
337
|
+
getSession: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
338
|
+
disableCookieCache?: unknown;
|
|
339
|
+
disableRefresh?: unknown;
|
|
340
|
+
}> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
341
|
+
query?: {
|
|
342
|
+
disableCookieCache?: unknown;
|
|
343
|
+
disableRefresh?: unknown;
|
|
344
|
+
} | undefined;
|
|
345
|
+
fetchOptions?: FetchOptions | undefined;
|
|
346
|
+
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
347
|
+
user: import("better-auth").StripEmptyObjects<{
|
|
348
|
+
id: string;
|
|
349
|
+
createdAt: Date;
|
|
350
|
+
updatedAt: Date;
|
|
351
|
+
email: string;
|
|
352
|
+
emailVerified: boolean;
|
|
353
|
+
name: string;
|
|
354
|
+
image?: string | null | undefined;
|
|
355
|
+
}>;
|
|
356
|
+
session: import("better-auth").StripEmptyObjects<{
|
|
357
|
+
id: string;
|
|
358
|
+
createdAt: Date;
|
|
359
|
+
updatedAt: Date;
|
|
360
|
+
userId: string;
|
|
361
|
+
expiresAt: Date;
|
|
362
|
+
token: string;
|
|
363
|
+
ipAddress?: string | null | undefined;
|
|
364
|
+
userAgent?: string | null | undefined;
|
|
365
|
+
}>;
|
|
366
|
+
} | null, {
|
|
367
|
+
code?: string | undefined;
|
|
368
|
+
message?: string | undefined;
|
|
369
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
370
|
+
/**
|
|
371
|
+
* Send (or re-send) an email-verification mail (`POST /send-verification-email`).
|
|
372
|
+
*
|
|
373
|
+
* A BARE passthrough, and it must stay one. `callbackURL` is the value Better Auth
|
|
374
|
+
* puts into the mail, and it MUST reach the server exactly as the caller wrote it:
|
|
375
|
+
* Better Auth resolves a relative value against the API origin, so `/auth/verify-email`
|
|
376
|
+
* lands on `api.<host>/auth/verify-email`, where the route does not exist. The mail
|
|
377
|
+
* still goes out, and the user follows a link to a 404 — the same silent failure
|
|
378
|
+
* `redirectTo` produces on the reset path.
|
|
379
|
+
*
|
|
380
|
+
* So do not normalise it here, do not supply a default, and do not resolve it against
|
|
381
|
+
* the client's `baseURL`. A library that quietly repairs the value hides the mistake
|
|
382
|
+
* until the next caller makes it somewhere we cannot see. Fixing it belongs to the
|
|
383
|
+
* caller (the lt starters use `appUrl()`, which throws rather than return something
|
|
384
|
+
* relative).
|
|
385
|
+
*/
|
|
386
|
+
sendVerificationEmail: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
387
|
+
email: string;
|
|
388
|
+
callbackURL?: string | undefined;
|
|
389
|
+
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
390
|
+
email: string;
|
|
391
|
+
callbackURL?: string | undefined;
|
|
392
|
+
} & {
|
|
393
|
+
fetchOptions?: FetchOptions | undefined;
|
|
394
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
395
|
+
status: boolean;
|
|
396
|
+
}, {
|
|
397
|
+
code?: string | undefined;
|
|
398
|
+
message?: string | undefined;
|
|
399
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
400
|
+
/**
|
|
401
|
+
* Verify an email address from a token (`POST /verify-email`).
|
|
402
|
+
*
|
|
403
|
+
* Carries no credential, so it is a bare passthrough. Note what the endpoint does with
|
|
404
|
+
* the query, because it decides the shape of the answer: WITH a `callbackURL` it
|
|
405
|
+
* answers `302` to that URL (carrying neither token nor status), WITHOUT one it answers
|
|
406
|
+
* `{ status: true }` as JSON. Callers that want the result rather than a redirect must
|
|
407
|
+
* therefore omit `callbackURL` here — which is not the same parameter as the one
|
|
408
|
+
* `sendVerificationEmail` puts into the mail, and confusing the two is easy.
|
|
409
|
+
*/
|
|
410
|
+
verifyEmail: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
411
|
+
token: string;
|
|
412
|
+
callbackURL?: string | undefined;
|
|
413
|
+
}> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
414
|
+
query: {
|
|
415
|
+
token: string;
|
|
416
|
+
callbackURL?: string | undefined;
|
|
417
|
+
};
|
|
418
|
+
fetchOptions?: FetchOptions | undefined;
|
|
419
|
+
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<NonNullable<void | {
|
|
420
|
+
status: boolean;
|
|
421
|
+
}>, {
|
|
422
|
+
code?: string | undefined;
|
|
423
|
+
message?: string | undefined;
|
|
424
|
+
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
332
425
|
requestPasswordReset: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
333
426
|
email: string;
|
|
334
427
|
redirectTo?: string | undefined;
|
|
@@ -519,91 +612,6 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
|
|
|
519
612
|
* @see https://www.better-auth.com/docs/plugins/passkey
|
|
520
613
|
*/
|
|
521
614
|
passkey: any;
|
|
522
|
-
social: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
523
|
-
provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat";
|
|
524
|
-
callbackURL?: string | undefined;
|
|
525
|
-
newUserCallbackURL?: string | undefined;
|
|
526
|
-
errorCallbackURL?: string | undefined;
|
|
527
|
-
disableRedirect?: boolean | undefined;
|
|
528
|
-
idToken?: {
|
|
529
|
-
token: string;
|
|
530
|
-
nonce?: string | undefined;
|
|
531
|
-
accessToken?: string | undefined;
|
|
532
|
-
refreshToken?: string | undefined;
|
|
533
|
-
expiresAt?: number | undefined;
|
|
534
|
-
user?: {
|
|
535
|
-
name?: {
|
|
536
|
-
firstName?: string | undefined;
|
|
537
|
-
lastName?: string | undefined;
|
|
538
|
-
} | undefined;
|
|
539
|
-
email?: string | undefined;
|
|
540
|
-
} | undefined;
|
|
541
|
-
} | undefined;
|
|
542
|
-
scopes?: string[] | undefined;
|
|
543
|
-
requestSignUp?: boolean | undefined;
|
|
544
|
-
loginHint?: string | undefined;
|
|
545
|
-
additionalParams?: Record<string, string> | undefined;
|
|
546
|
-
additionalData?: Record<string, any> | undefined;
|
|
547
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<Omit<{
|
|
548
|
-
provider: (string & {}) | "linear" | "huggingface" | "github" | "apple" | "atlassian" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat";
|
|
549
|
-
callbackURL?: string | undefined;
|
|
550
|
-
newUserCallbackURL?: string | undefined;
|
|
551
|
-
errorCallbackURL?: string | undefined;
|
|
552
|
-
disableRedirect?: boolean | undefined;
|
|
553
|
-
idToken?: {
|
|
554
|
-
token: string;
|
|
555
|
-
nonce?: string | undefined;
|
|
556
|
-
accessToken?: string | undefined;
|
|
557
|
-
refreshToken?: string | undefined;
|
|
558
|
-
expiresAt?: number | undefined;
|
|
559
|
-
user?: {
|
|
560
|
-
name?: {
|
|
561
|
-
firstName?: string | undefined;
|
|
562
|
-
lastName?: string | undefined;
|
|
563
|
-
} | undefined;
|
|
564
|
-
email?: string | undefined;
|
|
565
|
-
} | undefined;
|
|
566
|
-
} | undefined;
|
|
567
|
-
scopes?: string[] | undefined;
|
|
568
|
-
requestSignUp?: boolean | undefined;
|
|
569
|
-
loginHint?: string | undefined;
|
|
570
|
-
additionalParams?: Record<string, string> | undefined;
|
|
571
|
-
additionalData?: Record<string, any> | undefined;
|
|
572
|
-
} & {
|
|
573
|
-
fetchOptions?: FetchOptions | undefined;
|
|
574
|
-
}, "provider"> & {
|
|
575
|
-
provider: string | (string & {});
|
|
576
|
-
fetchOptions?: FetchOptions | undefined;
|
|
577
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
578
|
-
redirect: boolean;
|
|
579
|
-
url: string;
|
|
580
|
-
} | (Omit<{
|
|
581
|
-
redirect: boolean;
|
|
582
|
-
token: string;
|
|
583
|
-
url: undefined;
|
|
584
|
-
user: {
|
|
585
|
-
id: string;
|
|
586
|
-
createdAt: Date;
|
|
587
|
-
updatedAt: Date;
|
|
588
|
-
email: string;
|
|
589
|
-
emailVerified: boolean;
|
|
590
|
-
name: string;
|
|
591
|
-
image?: string | null | undefined | undefined;
|
|
592
|
-
};
|
|
593
|
-
}, "user"> & {
|
|
594
|
-
user: import("better-auth").StripEmptyObjects<{
|
|
595
|
-
id: string;
|
|
596
|
-
createdAt: Date;
|
|
597
|
-
updatedAt: Date;
|
|
598
|
-
email: string;
|
|
599
|
-
emailVerified: boolean;
|
|
600
|
-
name: string;
|
|
601
|
-
image?: string | null | undefined;
|
|
602
|
-
}>;
|
|
603
|
-
}), {
|
|
604
|
-
code?: string | undefined;
|
|
605
|
-
message?: string | undefined;
|
|
606
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
607
615
|
};
|
|
608
616
|
signOut: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
609
617
|
callbackURL?: string | undefined;
|
|
@@ -728,570 +736,33 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
|
|
|
728
736
|
};
|
|
729
737
|
}>;
|
|
730
738
|
};
|
|
731
|
-
twoFactor:
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
code?: string | undefined;
|
|
759
|
-
message?: string | undefined;
|
|
760
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
761
|
-
changeEmail: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
762
|
-
newEmail: string;
|
|
763
|
-
callbackURL?: string | undefined;
|
|
764
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
765
|
-
newEmail: string;
|
|
766
|
-
callbackURL?: string | undefined;
|
|
767
|
-
} & {
|
|
768
|
-
fetchOptions?: FetchOptions | undefined;
|
|
769
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
770
|
-
status: boolean;
|
|
771
|
-
}, {
|
|
772
|
-
code?: string | undefined;
|
|
773
|
-
message?: string | undefined;
|
|
774
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
775
|
-
updateSession: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<Partial<{}>> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0?: import("better-auth").Prettify<import("better-auth/client").InferSessionUpdateCtx<{
|
|
776
|
-
basePath: string;
|
|
777
|
-
baseURL: any;
|
|
778
|
-
fetchOptions: {
|
|
779
|
-
customFetchImpl: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
780
|
-
};
|
|
781
|
-
plugins: any[];
|
|
782
|
-
}, FetchOptions>> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
783
|
-
session: {
|
|
784
|
-
id: string;
|
|
785
|
-
createdAt: Date;
|
|
786
|
-
updatedAt: Date;
|
|
787
|
-
userId: string;
|
|
788
|
-
expiresAt: Date;
|
|
789
|
-
token: string;
|
|
790
|
-
ipAddress?: string | null | undefined;
|
|
791
|
-
userAgent?: string | null | undefined;
|
|
792
|
-
};
|
|
793
|
-
}, {
|
|
794
|
-
code?: string | undefined;
|
|
795
|
-
message?: string | undefined;
|
|
796
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
797
|
-
updateUser: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<Partial<{}> & {
|
|
798
|
-
name?: string | undefined;
|
|
799
|
-
image?: string | undefined | null;
|
|
800
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0?: import("better-auth").Prettify<import("better-auth/client").InferUserUpdateCtx<{
|
|
801
|
-
basePath: string;
|
|
802
|
-
baseURL: any;
|
|
803
|
-
fetchOptions: {
|
|
804
|
-
customFetchImpl: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
805
|
-
};
|
|
806
|
-
plugins: any[];
|
|
807
|
-
}, FetchOptions>> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
808
|
-
status: boolean;
|
|
809
|
-
}, {
|
|
810
|
-
code?: string | undefined;
|
|
811
|
-
message?: string | undefined;
|
|
812
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
813
|
-
deleteUser: (<FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
814
|
-
callbackURL?: string | undefined;
|
|
815
|
-
password?: string | undefined;
|
|
816
|
-
token?: string | undefined;
|
|
817
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
818
|
-
callbackURL?: string | undefined;
|
|
819
|
-
password?: string | undefined;
|
|
820
|
-
token?: string | undefined;
|
|
821
|
-
} & {
|
|
822
|
-
fetchOptions?: FetchOptions | undefined;
|
|
823
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
824
|
-
success: boolean;
|
|
825
|
-
message: string;
|
|
826
|
-
}, {
|
|
827
|
-
code?: string | undefined;
|
|
828
|
-
message?: string | undefined;
|
|
829
|
-
}, FetchOptions["throw"] extends true ? true : false>>) & {
|
|
830
|
-
callback: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
831
|
-
token: string;
|
|
832
|
-
callbackURL?: string | undefined;
|
|
833
|
-
}> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
834
|
-
query: {
|
|
835
|
-
token: string;
|
|
836
|
-
callbackURL?: string | undefined;
|
|
837
|
-
};
|
|
838
|
-
fetchOptions?: FetchOptions | undefined;
|
|
839
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
840
|
-
success: boolean;
|
|
841
|
-
message: string;
|
|
842
|
-
}, {
|
|
843
|
-
code?: string | undefined;
|
|
844
|
-
message?: string | undefined;
|
|
845
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
846
|
-
};
|
|
847
|
-
listSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
848
|
-
query?: Record<string, any> | undefined;
|
|
849
|
-
fetchOptions?: FetchOptions | undefined;
|
|
850
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<import("better-auth").Prettify<{
|
|
851
|
-
id: string;
|
|
852
|
-
createdAt: Date;
|
|
853
|
-
updatedAt: Date;
|
|
854
|
-
userId: string;
|
|
855
|
-
expiresAt: Date;
|
|
856
|
-
token: string;
|
|
857
|
-
ipAddress?: string | null | undefined | undefined;
|
|
858
|
-
userAgent?: string | null | undefined | undefined;
|
|
859
|
-
}>[], {
|
|
860
|
-
code?: string | undefined;
|
|
861
|
-
message?: string | undefined;
|
|
862
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
863
|
-
revokeSession: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
864
|
-
token: string;
|
|
865
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
866
|
-
token: string;
|
|
867
|
-
} & {
|
|
868
|
-
fetchOptions?: FetchOptions | undefined;
|
|
869
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
870
|
-
status: boolean;
|
|
871
|
-
}, {
|
|
872
|
-
code?: string | undefined;
|
|
873
|
-
message?: string | undefined;
|
|
874
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
875
|
-
revokeSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
876
|
-
query?: Record<string, any> | undefined;
|
|
877
|
-
fetchOptions?: FetchOptions | undefined;
|
|
878
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
879
|
-
status: boolean;
|
|
880
|
-
}, {
|
|
881
|
-
code?: string | undefined;
|
|
882
|
-
message?: string | undefined;
|
|
883
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
884
|
-
revokeOtherSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
885
|
-
query?: Record<string, any> | undefined;
|
|
886
|
-
fetchOptions?: FetchOptions | undefined;
|
|
887
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
888
|
-
status: boolean;
|
|
889
|
-
}, {
|
|
890
|
-
code?: string | undefined;
|
|
891
|
-
message?: string | undefined;
|
|
892
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
893
|
-
linkSocial: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
894
|
-
provider: unknown;
|
|
895
|
-
callbackURL?: string | undefined;
|
|
896
|
-
idToken?: {
|
|
897
|
-
token: string;
|
|
898
|
-
nonce?: string | undefined;
|
|
899
|
-
accessToken?: string | undefined;
|
|
900
|
-
refreshToken?: string | undefined;
|
|
901
|
-
} | undefined;
|
|
902
|
-
requestSignUp?: boolean | undefined;
|
|
903
|
-
scopes?: string[] | undefined;
|
|
904
|
-
errorCallbackURL?: string | undefined;
|
|
905
|
-
disableRedirect?: boolean | undefined;
|
|
906
|
-
loginHint?: string | undefined;
|
|
907
|
-
additionalParams?: Record<string, string> | undefined;
|
|
908
|
-
additionalData?: Record<string, any> | undefined;
|
|
909
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
910
|
-
provider: unknown;
|
|
911
|
-
callbackURL?: string | undefined;
|
|
912
|
-
idToken?: {
|
|
913
|
-
token: string;
|
|
914
|
-
nonce?: string | undefined;
|
|
915
|
-
accessToken?: string | undefined;
|
|
916
|
-
refreshToken?: string | undefined;
|
|
917
|
-
} | undefined;
|
|
918
|
-
requestSignUp?: boolean | undefined;
|
|
919
|
-
scopes?: string[] | undefined;
|
|
920
|
-
errorCallbackURL?: string | undefined;
|
|
921
|
-
disableRedirect?: boolean | undefined;
|
|
922
|
-
loginHint?: string | undefined;
|
|
923
|
-
additionalParams?: Record<string, string> | undefined;
|
|
924
|
-
additionalData?: Record<string, any> | undefined;
|
|
925
|
-
} & {
|
|
926
|
-
fetchOptions?: FetchOptions | undefined;
|
|
927
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
928
|
-
url: string;
|
|
929
|
-
redirect: boolean;
|
|
930
|
-
}, {
|
|
931
|
-
code?: string | undefined;
|
|
932
|
-
message?: string | undefined;
|
|
933
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
934
|
-
listAccounts: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
935
|
-
query?: Record<string, any> | undefined;
|
|
936
|
-
fetchOptions?: FetchOptions | undefined;
|
|
937
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
938
|
-
scopes: string[];
|
|
939
|
-
id: string;
|
|
940
|
-
createdAt: Date;
|
|
941
|
-
updatedAt: Date;
|
|
942
|
-
userId: string;
|
|
943
|
-
providerId: string;
|
|
944
|
-
issuer: string;
|
|
945
|
-
accountId: string;
|
|
946
|
-
}[], {
|
|
947
|
-
code?: string | undefined;
|
|
948
|
-
message?: string | undefined;
|
|
949
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
950
|
-
unlinkAccount: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
951
|
-
accountId: string;
|
|
952
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
953
|
-
accountId: string;
|
|
954
|
-
} & {
|
|
955
|
-
fetchOptions?: FetchOptions | undefined;
|
|
956
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
957
|
-
status: boolean;
|
|
958
|
-
}, {
|
|
959
|
-
code?: string | undefined;
|
|
960
|
-
message?: string | undefined;
|
|
961
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
962
|
-
refreshToken: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
963
|
-
accountId: string;
|
|
964
|
-
userId?: string | undefined;
|
|
965
|
-
} | {
|
|
966
|
-
useAccountCookie: true;
|
|
967
|
-
userId?: string | undefined;
|
|
968
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
969
|
-
accountId: string;
|
|
970
|
-
userId?: string | undefined;
|
|
971
|
-
} & {
|
|
972
|
-
fetchOptions?: FetchOptions | undefined;
|
|
973
|
-
}> | import("better-auth").Prettify<{
|
|
974
|
-
useAccountCookie: true;
|
|
975
|
-
userId?: string | undefined;
|
|
976
|
-
} & {
|
|
977
|
-
fetchOptions?: FetchOptions | undefined;
|
|
978
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
979
|
-
accessToken: string | undefined;
|
|
980
|
-
refreshToken: string;
|
|
981
|
-
accessTokenExpiresAt: Date | undefined;
|
|
982
|
-
refreshTokenExpiresAt: Date | null | undefined;
|
|
983
|
-
scope: string | null | undefined;
|
|
984
|
-
idToken: string | null | undefined;
|
|
985
|
-
providerId: string;
|
|
986
|
-
accountId: string;
|
|
987
|
-
}, {
|
|
988
|
-
code?: string | undefined;
|
|
989
|
-
message?: string | undefined;
|
|
990
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
991
|
-
getAccessToken: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
|
|
992
|
-
accountId: string;
|
|
993
|
-
userId?: string | undefined;
|
|
994
|
-
} | {
|
|
995
|
-
useAccountCookie: true;
|
|
996
|
-
userId?: string | undefined;
|
|
997
|
-
}> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
998
|
-
accountId: string;
|
|
999
|
-
userId?: string | undefined;
|
|
1000
|
-
} & {
|
|
1001
|
-
fetchOptions?: FetchOptions | undefined;
|
|
1002
|
-
}> | import("better-auth").Prettify<{
|
|
1003
|
-
useAccountCookie: true;
|
|
1004
|
-
userId?: string | undefined;
|
|
1005
|
-
} & {
|
|
1006
|
-
fetchOptions?: FetchOptions | undefined;
|
|
1007
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
1008
|
-
accessToken: string;
|
|
1009
|
-
accessTokenExpiresAt: Date | undefined;
|
|
1010
|
-
scopes: string[];
|
|
1011
|
-
idToken: string | undefined;
|
|
1012
|
-
}, {
|
|
1013
|
-
code?: string | undefined;
|
|
1014
|
-
message?: string | undefined;
|
|
1015
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
1016
|
-
accountInfo: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
1017
|
-
accountId: string;
|
|
1018
|
-
userId?: string | undefined;
|
|
1019
|
-
} | {
|
|
1020
|
-
useAccountCookie: true;
|
|
1021
|
-
userId?: string | undefined;
|
|
1022
|
-
}> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
|
|
1023
|
-
query: {
|
|
1024
|
-
accountId: string;
|
|
1025
|
-
userId?: string | undefined;
|
|
1026
|
-
} | {
|
|
1027
|
-
useAccountCookie: true;
|
|
1028
|
-
userId?: string | undefined;
|
|
1029
|
-
};
|
|
1030
|
-
fetchOptions?: FetchOptions | undefined;
|
|
1031
|
-
}>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
1032
|
-
account: {
|
|
1033
|
-
id: string;
|
|
1034
|
-
providerId: string;
|
|
1035
|
-
issuer: string;
|
|
1036
|
-
accountId: string;
|
|
1037
|
-
};
|
|
1038
|
-
user: import("better-auth").OAuth2UserInfo;
|
|
1039
|
-
data: object;
|
|
1040
|
-
}, {
|
|
1041
|
-
code?: string | undefined;
|
|
1042
|
-
message?: string | undefined;
|
|
1043
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
1044
|
-
getSession: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
|
|
1045
|
-
disableCookieCache?: unknown;
|
|
1046
|
-
disableRefresh?: unknown;
|
|
1047
|
-
}> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0?: import("better-auth").Prettify<{
|
|
1048
|
-
query?: {
|
|
1049
|
-
disableCookieCache?: unknown;
|
|
1050
|
-
disableRefresh?: unknown;
|
|
1051
|
-
} | undefined;
|
|
1052
|
-
fetchOptions?: FetchOptions | undefined;
|
|
1053
|
-
}> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
|
|
1054
|
-
user: import("better-auth").StripEmptyObjects<{
|
|
1055
|
-
id: string;
|
|
1056
|
-
createdAt: Date;
|
|
1057
|
-
updatedAt: Date;
|
|
1058
|
-
email: string;
|
|
1059
|
-
emailVerified: boolean;
|
|
1060
|
-
name: string;
|
|
1061
|
-
image?: string | null | undefined;
|
|
1062
|
-
}>;
|
|
1063
|
-
session: import("better-auth").StripEmptyObjects<{
|
|
1064
|
-
id: string;
|
|
1065
|
-
createdAt: Date;
|
|
1066
|
-
updatedAt: Date;
|
|
1067
|
-
userId: string;
|
|
1068
|
-
expiresAt: Date;
|
|
1069
|
-
token: string;
|
|
1070
|
-
ipAddress?: string | null | undefined;
|
|
1071
|
-
userAgent?: string | null | undefined;
|
|
1072
|
-
}>;
|
|
1073
|
-
} | null, {
|
|
1074
|
-
code?: string | undefined;
|
|
1075
|
-
message?: string | undefined;
|
|
1076
|
-
}, FetchOptions["throw"] extends true ? true : false>>;
|
|
1077
|
-
hydrateSession: (session: {
|
|
1078
|
-
user: import("better-auth").StripEmptyObjects<{
|
|
1079
|
-
id: string;
|
|
1080
|
-
createdAt: Date;
|
|
1081
|
-
updatedAt: Date;
|
|
1082
|
-
email: string;
|
|
1083
|
-
emailVerified: boolean;
|
|
1084
|
-
name: string;
|
|
1085
|
-
image?: string | null | undefined;
|
|
1086
|
-
}>;
|
|
1087
|
-
session: import("better-auth").StripEmptyObjects<{
|
|
1088
|
-
id: string;
|
|
1089
|
-
createdAt: Date;
|
|
1090
|
-
updatedAt: Date;
|
|
1091
|
-
userId: string;
|
|
1092
|
-
expiresAt: Date;
|
|
1093
|
-
token: string;
|
|
1094
|
-
ipAddress?: string | null | undefined;
|
|
1095
|
-
userAgent?: string | null | undefined;
|
|
1096
|
-
}>;
|
|
1097
|
-
} | null) => void;
|
|
1098
|
-
$ERROR_CODES: {
|
|
1099
|
-
USER_NOT_FOUND: {
|
|
1100
|
-
readonly code: "USER_NOT_FOUND";
|
|
1101
|
-
message: string;
|
|
1102
|
-
};
|
|
1103
|
-
FAILED_TO_CREATE_USER: {
|
|
1104
|
-
readonly code: "FAILED_TO_CREATE_USER";
|
|
1105
|
-
message: string;
|
|
1106
|
-
};
|
|
1107
|
-
FAILED_TO_CREATE_SESSION: {
|
|
1108
|
-
readonly code: "FAILED_TO_CREATE_SESSION";
|
|
1109
|
-
message: string;
|
|
1110
|
-
};
|
|
1111
|
-
FAILED_TO_UPDATE_USER: {
|
|
1112
|
-
readonly code: "FAILED_TO_UPDATE_USER";
|
|
1113
|
-
message: string;
|
|
1114
|
-
};
|
|
1115
|
-
FAILED_TO_GET_SESSION: {
|
|
1116
|
-
readonly code: "FAILED_TO_GET_SESSION";
|
|
1117
|
-
message: string;
|
|
1118
|
-
};
|
|
1119
|
-
INVALID_PASSWORD: {
|
|
1120
|
-
readonly code: "INVALID_PASSWORD";
|
|
1121
|
-
message: string;
|
|
1122
|
-
};
|
|
1123
|
-
INVALID_EMAIL: {
|
|
1124
|
-
readonly code: "INVALID_EMAIL";
|
|
1125
|
-
message: string;
|
|
1126
|
-
};
|
|
1127
|
-
INVALID_EMAIL_OR_PASSWORD: {
|
|
1128
|
-
readonly code: "INVALID_EMAIL_OR_PASSWORD";
|
|
1129
|
-
message: string;
|
|
1130
|
-
};
|
|
1131
|
-
INVALID_USER: {
|
|
1132
|
-
readonly code: "INVALID_USER";
|
|
1133
|
-
message: string;
|
|
1134
|
-
};
|
|
1135
|
-
SOCIAL_ACCOUNT_ALREADY_LINKED: {
|
|
1136
|
-
readonly code: "SOCIAL_ACCOUNT_ALREADY_LINKED";
|
|
1137
|
-
message: string;
|
|
1138
|
-
};
|
|
1139
|
-
PROVIDER_NOT_FOUND: {
|
|
1140
|
-
readonly code: "PROVIDER_NOT_FOUND";
|
|
1141
|
-
message: string;
|
|
1142
|
-
};
|
|
1143
|
-
INVALID_TOKEN: {
|
|
1144
|
-
readonly code: "INVALID_TOKEN";
|
|
1145
|
-
message: string;
|
|
1146
|
-
};
|
|
1147
|
-
TOKEN_EXPIRED: {
|
|
1148
|
-
readonly code: "TOKEN_EXPIRED";
|
|
1149
|
-
message: string;
|
|
1150
|
-
};
|
|
1151
|
-
ID_TOKEN_NOT_SUPPORTED: {
|
|
1152
|
-
readonly code: "ID_TOKEN_NOT_SUPPORTED";
|
|
1153
|
-
message: string;
|
|
1154
|
-
};
|
|
1155
|
-
FAILED_TO_GET_USER_INFO: {
|
|
1156
|
-
readonly code: "FAILED_TO_GET_USER_INFO";
|
|
1157
|
-
message: string;
|
|
1158
|
-
};
|
|
1159
|
-
USER_EMAIL_NOT_FOUND: {
|
|
1160
|
-
readonly code: "USER_EMAIL_NOT_FOUND";
|
|
1161
|
-
message: string;
|
|
1162
|
-
};
|
|
1163
|
-
EMAIL_NOT_VERIFIED: {
|
|
1164
|
-
readonly code: "EMAIL_NOT_VERIFIED";
|
|
1165
|
-
message: string;
|
|
1166
|
-
};
|
|
1167
|
-
PASSWORD_TOO_SHORT: {
|
|
1168
|
-
readonly code: "PASSWORD_TOO_SHORT";
|
|
1169
|
-
message: string;
|
|
1170
|
-
};
|
|
1171
|
-
PASSWORD_TOO_LONG: {
|
|
1172
|
-
readonly code: "PASSWORD_TOO_LONG";
|
|
1173
|
-
message: string;
|
|
1174
|
-
};
|
|
1175
|
-
USER_ALREADY_EXISTS: {
|
|
1176
|
-
readonly code: "USER_ALREADY_EXISTS";
|
|
1177
|
-
message: string;
|
|
1178
|
-
};
|
|
1179
|
-
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: {
|
|
1180
|
-
readonly code: "USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL";
|
|
1181
|
-
message: string;
|
|
1182
|
-
};
|
|
1183
|
-
EMAIL_CAN_NOT_BE_UPDATED: {
|
|
1184
|
-
readonly code: "EMAIL_CAN_NOT_BE_UPDATED";
|
|
1185
|
-
message: string;
|
|
1186
|
-
};
|
|
1187
|
-
CHANGE_EMAIL_DISABLED: {
|
|
1188
|
-
readonly code: "CHANGE_EMAIL_DISABLED";
|
|
1189
|
-
message: string;
|
|
1190
|
-
};
|
|
1191
|
-
CREDENTIAL_ACCOUNT_NOT_FOUND: {
|
|
1192
|
-
readonly code: "CREDENTIAL_ACCOUNT_NOT_FOUND";
|
|
1193
|
-
message: string;
|
|
1194
|
-
};
|
|
1195
|
-
ACCOUNT_NOT_FOUND: {
|
|
1196
|
-
readonly code: "ACCOUNT_NOT_FOUND";
|
|
1197
|
-
message: string;
|
|
1198
|
-
};
|
|
1199
|
-
SESSION_EXPIRED: {
|
|
1200
|
-
readonly code: "SESSION_EXPIRED";
|
|
1201
|
-
message: string;
|
|
1202
|
-
};
|
|
1203
|
-
FAILED_TO_UNLINK_LAST_ACCOUNT: {
|
|
1204
|
-
readonly code: "FAILED_TO_UNLINK_LAST_ACCOUNT";
|
|
1205
|
-
message: string;
|
|
1206
|
-
};
|
|
1207
|
-
USER_ALREADY_HAS_PASSWORD: {
|
|
1208
|
-
readonly code: "USER_ALREADY_HAS_PASSWORD";
|
|
1209
|
-
message: string;
|
|
1210
|
-
};
|
|
1211
|
-
CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: {
|
|
1212
|
-
readonly code: "CROSS_SITE_NAVIGATION_LOGIN_BLOCKED";
|
|
1213
|
-
message: string;
|
|
1214
|
-
};
|
|
1215
|
-
VERIFICATION_EMAIL_NOT_ENABLED: {
|
|
1216
|
-
readonly code: "VERIFICATION_EMAIL_NOT_ENABLED";
|
|
1217
|
-
message: string;
|
|
1218
|
-
};
|
|
1219
|
-
EMAIL_ALREADY_VERIFIED: {
|
|
1220
|
-
readonly code: "EMAIL_ALREADY_VERIFIED";
|
|
1221
|
-
message: string;
|
|
1222
|
-
};
|
|
1223
|
-
EMAIL_MISMATCH: {
|
|
1224
|
-
readonly code: "EMAIL_MISMATCH";
|
|
1225
|
-
message: string;
|
|
1226
|
-
};
|
|
1227
|
-
SESSION_NOT_FRESH: {
|
|
1228
|
-
readonly code: "SESSION_NOT_FRESH";
|
|
1229
|
-
message: string;
|
|
1230
|
-
};
|
|
1231
|
-
LINKED_ACCOUNT_ALREADY_EXISTS: {
|
|
1232
|
-
readonly code: "LINKED_ACCOUNT_ALREADY_EXISTS";
|
|
1233
|
-
message: string;
|
|
1234
|
-
};
|
|
1235
|
-
INVALID_ORIGIN: {
|
|
1236
|
-
readonly code: "INVALID_ORIGIN";
|
|
1237
|
-
message: string;
|
|
1238
|
-
};
|
|
1239
|
-
INVALID_CALLBACK_URL: {
|
|
1240
|
-
readonly code: "INVALID_CALLBACK_URL";
|
|
1241
|
-
message: string;
|
|
1242
|
-
};
|
|
1243
|
-
INVALID_REDIRECT_URL: {
|
|
1244
|
-
readonly code: "INVALID_REDIRECT_URL";
|
|
1245
|
-
message: string;
|
|
1246
|
-
};
|
|
1247
|
-
INVALID_ERROR_CALLBACK_URL: {
|
|
1248
|
-
readonly code: "INVALID_ERROR_CALLBACK_URL";
|
|
1249
|
-
message: string;
|
|
1250
|
-
};
|
|
1251
|
-
INVALID_NEW_USER_CALLBACK_URL: {
|
|
1252
|
-
readonly code: "INVALID_NEW_USER_CALLBACK_URL";
|
|
1253
|
-
message: string;
|
|
1254
|
-
};
|
|
1255
|
-
MISSING_OR_NULL_ORIGIN: {
|
|
1256
|
-
readonly code: "MISSING_OR_NULL_ORIGIN";
|
|
1257
|
-
message: string;
|
|
1258
|
-
};
|
|
1259
|
-
CALLBACK_URL_REQUIRED: {
|
|
1260
|
-
readonly code: "CALLBACK_URL_REQUIRED";
|
|
1261
|
-
message: string;
|
|
1262
|
-
};
|
|
1263
|
-
FAILED_TO_CREATE_VERIFICATION: {
|
|
1264
|
-
readonly code: "FAILED_TO_CREATE_VERIFICATION";
|
|
1265
|
-
message: string;
|
|
1266
|
-
};
|
|
1267
|
-
FIELD_NOT_ALLOWED: {
|
|
1268
|
-
readonly code: "FIELD_NOT_ALLOWED";
|
|
1269
|
-
message: string;
|
|
1270
|
-
};
|
|
1271
|
-
ASYNC_VALIDATION_NOT_SUPPORTED: {
|
|
1272
|
-
readonly code: "ASYNC_VALIDATION_NOT_SUPPORTED";
|
|
1273
|
-
message: string;
|
|
1274
|
-
};
|
|
1275
|
-
VALIDATION_ERROR: {
|
|
1276
|
-
readonly code: "VALIDATION_ERROR";
|
|
1277
|
-
message: string;
|
|
1278
|
-
};
|
|
1279
|
-
MISSING_FIELD: {
|
|
1280
|
-
readonly code: "MISSING_FIELD";
|
|
1281
|
-
message: string;
|
|
1282
|
-
};
|
|
1283
|
-
METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED: {
|
|
1284
|
-
readonly code: "METHOD_NOT_ALLOWED_DEFER_SESSION_REQUIRED";
|
|
1285
|
-
message: string;
|
|
1286
|
-
};
|
|
1287
|
-
BODY_MUST_BE_AN_OBJECT: {
|
|
1288
|
-
readonly code: "BODY_MUST_BE_AN_OBJECT";
|
|
1289
|
-
message: string;
|
|
1290
|
-
};
|
|
1291
|
-
PASSWORD_ALREADY_SET: {
|
|
1292
|
-
readonly code: "PASSWORD_ALREADY_SET";
|
|
1293
|
-
message: string;
|
|
1294
|
-
};
|
|
739
|
+
twoFactor: {
|
|
740
|
+
/**
|
|
741
|
+
* Disable 2FA (password is hashed before sending)
|
|
742
|
+
*/
|
|
743
|
+
disable: <T extends {
|
|
744
|
+
password: string;
|
|
745
|
+
}>(params: T, options?: any) => Promise<any>;
|
|
746
|
+
/**
|
|
747
|
+
* Enable 2FA (password is hashed before sending)
|
|
748
|
+
*/
|
|
749
|
+
enable: <T extends {
|
|
750
|
+
password: string;
|
|
751
|
+
}>(params: T, options?: any) => Promise<any>;
|
|
752
|
+
/**
|
|
753
|
+
* Generate backup codes (password is hashed before sending)
|
|
754
|
+
*/
|
|
755
|
+
generateBackupCodes: <T extends {
|
|
756
|
+
password: string;
|
|
757
|
+
}>(params: T, options?: any) => Promise<any>;
|
|
758
|
+
/**
|
|
759
|
+
* Verify TOTP code (pass through to base client)
|
|
760
|
+
*/
|
|
761
|
+
verifyTotp: any;
|
|
762
|
+
/**
|
|
763
|
+
* Verify backup code (pass through to base client)
|
|
764
|
+
*/
|
|
765
|
+
verifyBackupCode: any;
|
|
1295
766
|
};
|
|
1296
767
|
};
|
|
1297
768
|
export type LtAuthClient = ReturnType<typeof createLtAuthClient>;
|
|
@@ -79,9 +79,6 @@ export function createLtAuthClient(config = {}) {
|
|
|
79
79
|
plugins
|
|
80
80
|
});
|
|
81
81
|
return {
|
|
82
|
-
// Spread all base client properties and methods
|
|
83
|
-
...baseClient,
|
|
84
|
-
// Explicitly pass through methods not captured by spread operator
|
|
85
82
|
useSession: baseClient.useSession,
|
|
86
83
|
passkey: baseClient.passkey,
|
|
87
84
|
/**
|
|
@@ -108,6 +105,40 @@ export function createLtAuthClient(config = {}) {
|
|
|
108
105
|
$Infer: baseClient.$Infer,
|
|
109
106
|
$fetch: baseClient.$fetch,
|
|
110
107
|
$store: baseClient.$store,
|
|
108
|
+
/**
|
|
109
|
+
* Read the current session (`GET /get-session`).
|
|
110
|
+
*
|
|
111
|
+
* Carries no credential, so it is a bare passthrough.
|
|
112
|
+
*/
|
|
113
|
+
getSession: baseClient.getSession,
|
|
114
|
+
/**
|
|
115
|
+
* Send (or re-send) an email-verification mail (`POST /send-verification-email`).
|
|
116
|
+
*
|
|
117
|
+
* A BARE passthrough, and it must stay one. `callbackURL` is the value Better Auth
|
|
118
|
+
* puts into the mail, and it MUST reach the server exactly as the caller wrote it:
|
|
119
|
+
* Better Auth resolves a relative value against the API origin, so `/auth/verify-email`
|
|
120
|
+
* lands on `api.<host>/auth/verify-email`, where the route does not exist. The mail
|
|
121
|
+
* still goes out, and the user follows a link to a 404 — the same silent failure
|
|
122
|
+
* `redirectTo` produces on the reset path.
|
|
123
|
+
*
|
|
124
|
+
* So do not normalise it here, do not supply a default, and do not resolve it against
|
|
125
|
+
* the client's `baseURL`. A library that quietly repairs the value hides the mistake
|
|
126
|
+
* until the next caller makes it somewhere we cannot see. Fixing it belongs to the
|
|
127
|
+
* caller (the lt starters use `appUrl()`, which throws rather than return something
|
|
128
|
+
* relative).
|
|
129
|
+
*/
|
|
130
|
+
sendVerificationEmail: baseClient.sendVerificationEmail,
|
|
131
|
+
/**
|
|
132
|
+
* Verify an email address from a token (`POST /verify-email`).
|
|
133
|
+
*
|
|
134
|
+
* Carries no credential, so it is a bare passthrough. Note what the endpoint does with
|
|
135
|
+
* the query, because it decides the shape of the answer: WITH a `callbackURL` it
|
|
136
|
+
* answers `302` to that URL (carrying neither token nor status), WITHOUT one it answers
|
|
137
|
+
* `{ status: true }` as JSON. Callers that want the result rather than a redirect must
|
|
138
|
+
* therefore omit `callbackURL` here — which is not the same parameter as the one
|
|
139
|
+
* `sendVerificationEmail` puts into the mail, and confusing the two is easy.
|
|
140
|
+
*/
|
|
141
|
+
verifyEmail: baseClient.verifyEmail,
|
|
111
142
|
// Deliberately a bare passthrough: it takes an email address, never a password, so
|
|
112
143
|
// there is nothing to hash — and passing it through untouched is what keeps
|
|
113
144
|
// `redirectTo` intact (see the note above `resetPassword`).
|
|
@@ -138,9 +169,14 @@ export function createLtAuthClient(config = {}) {
|
|
|
138
169
|
}
|
|
139
170
|
return baseClient.resetPassword({ ...params, newPassword: hashedPassword }, options);
|
|
140
171
|
},
|
|
141
|
-
// Override signIn to hash password (keep passkey method from plugin)
|
|
172
|
+
// Override signIn to hash password (keep passkey method from plugin).
|
|
173
|
+
//
|
|
174
|
+
// No `...baseClient.signIn` here, for the reason given at the top of this object: the
|
|
175
|
+
// sub-objects are proxies too. `Object.keys(baseClient.signIn)` is `[]`, so the spread
|
|
176
|
+
// copied nothing while the type declared everything — `signIn.social` type-checked and
|
|
177
|
+
// was `undefined` when called. 1.17.0 removed the top-level spread and left these three,
|
|
178
|
+
// which is how the same defect survived its own fix.
|
|
142
179
|
signIn: {
|
|
143
|
-
...baseClient.signIn,
|
|
144
180
|
/**
|
|
145
181
|
* Sign in with email and password (password is hashed before sending)
|
|
146
182
|
*/
|
|
@@ -156,9 +192,8 @@ export function createLtAuthClient(config = {}) {
|
|
|
156
192
|
},
|
|
157
193
|
// Explicitly pass through signOut (not captured by spread operator)
|
|
158
194
|
signOut: baseClient.signOut,
|
|
159
|
-
// Override signUp to hash password
|
|
195
|
+
// Override signUp to hash password. No spread — see `signIn` above.
|
|
160
196
|
signUp: {
|
|
161
|
-
...baseClient.signUp,
|
|
162
197
|
/**
|
|
163
198
|
* Sign up with email and password (password is hashed before sending)
|
|
164
199
|
*/
|
|
@@ -168,8 +203,12 @@ export function createLtAuthClient(config = {}) {
|
|
|
168
203
|
}
|
|
169
204
|
},
|
|
170
205
|
// Override twoFactor to hash passwords (provided by twoFactorClient plugin)
|
|
206
|
+
// No spread — see `signIn` above. This is the sub-object where it mattered most:
|
|
207
|
+
// `getTotpUri`, `sendOtp` and `verifyOtp` were declared by the type and `undefined` at
|
|
208
|
+
// runtime, and `getTotpUri` is what a project reaches for to render the TOTP QR code.
|
|
209
|
+
// They are not added here because none has a caller yet; each listed method is a promise
|
|
210
|
+
// this package then keeps across versions. Ask, and it gets a line.
|
|
171
211
|
twoFactor: {
|
|
172
|
-
...baseClient.twoFactor,
|
|
173
212
|
/**
|
|
174
213
|
* Disable 2FA (password is hashed before sending)
|
|
175
214
|
*/
|
|
@@ -10,6 +10,10 @@ export interface LtUser {
|
|
|
10
10
|
email: string;
|
|
11
11
|
emailVerified?: boolean;
|
|
12
12
|
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* Stored as `string | undefined`, never `null` — see {@link LtUserInput}, which is what
|
|
15
|
+
* `setUser` accepts. Reading code therefore has one empty case to handle, not two.
|
|
16
|
+
*/
|
|
13
17
|
image?: string;
|
|
14
18
|
name?: string;
|
|
15
19
|
/** Single-role shape (Better-Auth admin plugin). See also {@link LtUser.roles}. */
|
|
@@ -30,6 +34,24 @@ export interface LtUser {
|
|
|
30
34
|
roles?: string[];
|
|
31
35
|
twoFactorEnabled?: boolean;
|
|
32
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* What {@link UseLtAuthReturn.setUser} accepts: an {@link LtUser} whose `image` may also be
|
|
39
|
+
* `null`.
|
|
40
|
+
*
|
|
41
|
+
* Better Auth's session user declares `image?: string | null | undefined`
|
|
42
|
+
* (`@better-auth/core`), so handing `getSession().data.user` straight to `setUser` did not
|
|
43
|
+
* type-check — the two sides mean the same thing by "no picture" and write it differently.
|
|
44
|
+
* Every consumer combining them wrote the same normalising line, and this package's own call
|
|
45
|
+
* sites hid it behind `as LtUser`, which is why it went unnoticed until 1.17.0 exposed
|
|
46
|
+
* `getSession()` and gave that path a real type.
|
|
47
|
+
*
|
|
48
|
+
* `setUser` normalises `null` to `undefined` on the way in, so the stored user and every
|
|
49
|
+
* reader keep the single empty case. Widening `LtUser.image` itself would have done the
|
|
50
|
+
* opposite: pushed a second empty value onto everyone who only READS it.
|
|
51
|
+
*/
|
|
52
|
+
export type LtUserInput = Omit<LtUser, 'image'> & {
|
|
53
|
+
image?: null | string;
|
|
54
|
+
};
|
|
33
55
|
/**
|
|
34
56
|
* Authentication mode for Cookie/JWT dual-mode authentication
|
|
35
57
|
* - 'cookie': Primary mode using HttpOnly session cookies (more secure)
|
|
@@ -251,7 +273,14 @@ export interface UseLtAuthReturn {
|
|
|
251
273
|
newPassword: string;
|
|
252
274
|
token: string;
|
|
253
275
|
}>(params: NoStrayCredential<T, 'newPassword'>, options?: unknown) => Promise<unknown>;
|
|
254
|
-
|
|
276
|
+
/**
|
|
277
|
+
* Store the authenticated user.
|
|
278
|
+
*
|
|
279
|
+
* Accepts {@link LtUserInput}, so `getSession().data.user` can be handed over unchanged —
|
|
280
|
+
* Better Auth writes "no picture" as `image: null`, which this normalises to `undefined`
|
|
281
|
+
* before storing. Readers of {@link LtUser} keep a single empty case.
|
|
282
|
+
*/
|
|
283
|
+
setUser: (userData: LtUserInput | null, mode?: LtAuthMode) => void;
|
|
255
284
|
signIn: {
|
|
256
285
|
email: <T extends {
|
|
257
286
|
email: string;
|
|
@@ -31,7 +31,32 @@ export interface LtErrorTranslationModuleOptions {
|
|
|
31
31
|
* Return type for useLtErrorTranslation composable
|
|
32
32
|
*/
|
|
33
33
|
export interface UseLtErrorTranslationReturn {
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Translate an error message or code to a user-friendly message.
|
|
36
|
+
*
|
|
37
|
+
* ALWAYS returns a usable string, which has two consequences worth knowing before you
|
|
38
|
+
* write the call.
|
|
39
|
+
*
|
|
40
|
+
* **`translateError(x) || 'Fallback'` never reaches the fallback.** When the message
|
|
41
|
+
* carries no `#CODE:` marker, the original message is returned unchanged — non-empty,
|
|
42
|
+
* therefore truthy. Only an error with no message at all can produce `''`. The `||`
|
|
43
|
+
* reads like a safety net, catches nothing, and hides that the untranslated English text
|
|
44
|
+
* is what the user actually sees. Six pages in one starter had it before anyone noticed.
|
|
45
|
+
* If you want a fallback, decide on {@link LtParsedError.code} being `null`.
|
|
46
|
+
*
|
|
47
|
+
* **Branch on the code, not on the message.** Backends give one message per situation
|
|
48
|
+
* but not one situation per status: Better Auth answers `POST /reset-password` with five
|
|
49
|
+
* different errors under the same `400`. Only the code separates them, and only codes
|
|
50
|
+
* the backend has mapped arrive with a `#LTNS_` marker at all — anything unmapped falls
|
|
51
|
+
* through as raw English, by design rather than by omission.
|
|
52
|
+
*
|
|
53
|
+
* **A raw `$fetch` error can be passed straight in.** ofetch's `FetchError` keeps the
|
|
54
|
+
* transport line in `message` (`[POST] "/iam/reset-password": 400 Bad Request`) and the
|
|
55
|
+
* parsed response body in `data`; extraction reads `data.message` first, so the
|
|
56
|
+
* backend's own message is what gets translated. Unwrapping it at the call site
|
|
57
|
+
* (`err.data?.message ?? err`) is therefore no longer necessary — it stays harmless, but
|
|
58
|
+
* a helper built for it can go.
|
|
59
|
+
*/
|
|
35
60
|
translateError: (errorOrMessage: unknown) => string;
|
|
36
61
|
/** Parse a backend error to extract code and messages */
|
|
37
62
|
parseError: (errorOrMessage: unknown) => LtParsedError;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, LtUser, UseLtAuthReturn } from './auth.js';
|
|
1
|
+
export type { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, 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, 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": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"prepack": "node scripts/sync-module-version.mjs && nuxt-module-build build",
|
|
52
52
|
"c": "pnpm run check",
|
|
53
53
|
"check": "node scripts/check.mjs",
|
|
54
|
-
"check:raw": "pnpm install --frozen-lockfile && pnpm audit && pnpm run format:check && pnpm run lint && pnpm run version:check && pnpm run dev:prepare && pnpm test:types && pnpm test && pnpm run build && pnpm run check:manifest",
|
|
55
|
-
"check:fix": "pnpm install && pnpm audit --fix && pnpm run format && pnpm run lint:fix && pnpm run version:sync && pnpm test:types && pnpm test && pnpm run build && pnpm run check:manifest",
|
|
56
|
-
"check:naf": "pnpm install && pnpm run format && pnpm run lint:fix && pnpm run version:sync && pnpm test:types && pnpm test && pnpm run build && pnpm run check:manifest",
|
|
54
|
+
"check:raw": "pnpm install --frozen-lockfile && pnpm audit && pnpm peers check && pnpm run format:check && pnpm run lint && pnpm run version:check && pnpm run dev:prepare && pnpm test:types && pnpm test && pnpm run build && pnpm run check:manifest",
|
|
55
|
+
"check:fix": "pnpm install && pnpm audit --fix && pnpm peers check && pnpm run format && pnpm run lint:fix && pnpm run version:sync && pnpm test:types && pnpm test && pnpm run build && pnpm run check:manifest",
|
|
56
|
+
"check:naf": "pnpm install && pnpm peers check && pnpm run format && pnpm run lint:fix && pnpm run version:sync && pnpm test:types && pnpm test && pnpm run build && pnpm run check:manifest",
|
|
57
57
|
"cf": "pnpm run check:fix",
|
|
58
58
|
"cnaf": "pnpm run check:naf",
|
|
59
59
|
"dev": "pnpm dev:prepare && nuxt dev playground",
|