@lenne.tech/nuxt-extensions 1.16.0 → 1.17.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 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.16.0";
6
+ declare const version = "1.17.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "configKey": "ltExtensions",
3
3
  "name": "@lenne.tech/nuxt-extensions",
4
- "version": "1.16.0",
4
+ "version": "1.17.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.3",
7
7
  "unbuild": "3.6.1"
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.16.0";
5
+ const version = "1.17.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";
@@ -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;
@@ -729,569 +822,5 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
729
822
  }>;
730
823
  };
731
824
  twoFactor: any;
732
- verifyEmail: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<{
733
- token: string;
734
- callbackURL?: string | undefined;
735
- }> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
736
- query: {
737
- token: string;
738
- callbackURL?: string | undefined;
739
- };
740
- fetchOptions?: FetchOptions | undefined;
741
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<NonNullable<void | {
742
- status: boolean;
743
- }>, {
744
- code?: string | undefined;
745
- message?: string | undefined;
746
- }, FetchOptions["throw"] extends true ? true : false>>;
747
- sendVerificationEmail: <FetchOptions extends import("better-auth").ClientFetchOption<Partial<{
748
- email: string;
749
- callbackURL?: string | undefined;
750
- }> & Record<string, any>, Partial<Record<string, any>> & Record<string, any>, Record<string, string | undefined> | undefined>>(data_0: import("better-auth").Prettify<{
751
- email: string;
752
- callbackURL?: string | undefined;
753
- } & {
754
- fetchOptions?: FetchOptions | undefined;
755
- }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
756
- status: boolean;
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
- };
1295
- };
1296
825
  };
1297
826
  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`).
@@ -31,7 +31,32 @@ export interface LtErrorTranslationModuleOptions {
31
31
  * Return type for useLtErrorTranslation composable
32
32
  */
33
33
  export interface UseLtErrorTranslationReturn {
34
- /** Translate an error message or code to user-friendly message */
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nuxt-extensions",
3
- "version": "1.16.0",
3
+ "version": "1.17.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",