@lenne.tech/nuxt-extensions 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { useNuxtApp } from "#imports";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createLtAuthClient,
|
|
4
|
+
setResetAuthClientCallback
|
|
5
|
+
} from "../lib/auth-client.js";
|
|
3
6
|
let authClientInstance = null;
|
|
4
7
|
export function resetLtAuthClient() {
|
|
5
8
|
authClientInstance = null;
|
|
6
9
|
}
|
|
10
|
+
setResetAuthClientCallback(resetLtAuthClient);
|
|
7
11
|
function isDevMode() {
|
|
8
12
|
if (import.meta.server) {
|
|
9
13
|
return process.env.NODE_ENV !== "production";
|
|
@@ -8,16 +8,24 @@
|
|
|
8
8
|
* plain text password transmission over the network.
|
|
9
9
|
*/
|
|
10
10
|
import type { LtAuthClientConfig } from "../types/index.js";
|
|
11
|
+
/**
|
|
12
|
+
* Set the callback to reset the auth client.
|
|
13
|
+
* Called internally by use-lt-auth-client.ts
|
|
14
|
+
*/
|
|
15
|
+
export declare function setResetAuthClientCallback(callback: () => void): void;
|
|
11
16
|
/**
|
|
12
17
|
* Register additional Better Auth plugins before auth client initialization.
|
|
13
18
|
*
|
|
14
19
|
* Call this in a Nuxt plugin (client-side) or in app.vue setup before
|
|
15
20
|
* the auth client is used.
|
|
16
21
|
*
|
|
22
|
+
* If the auth client was already created, it will be automatically reset
|
|
23
|
+
* so the next call recreates it with the new plugins.
|
|
24
|
+
*
|
|
17
25
|
* @example
|
|
18
26
|
* ```typescript
|
|
19
27
|
* // plugins/auth-plugins.client.ts
|
|
20
|
-
* import { registerLtAuthPlugins } from '@lenne.tech/nuxt-extensions';
|
|
28
|
+
* import { registerLtAuthPlugins } from '@lenne.tech/nuxt-extensions/lib';
|
|
21
29
|
* import { organizationClient, magicLinkClient } from 'better-auth/client/plugins';
|
|
22
30
|
*
|
|
23
31
|
* export default defineNuxtPlugin(() => {
|
|
@@ -5,8 +5,15 @@ import { navigateTo } from "#imports";
|
|
|
5
5
|
import { ltSha256 } from "../utils/crypto.js";
|
|
6
6
|
import { createLtAuthFetch, isLtDevMode } from "./auth-state.js";
|
|
7
7
|
let _ltAuthPluginRegistry = [];
|
|
8
|
+
let _resetAuthClientCallback = null;
|
|
9
|
+
export function setResetAuthClientCallback(callback) {
|
|
10
|
+
_resetAuthClientCallback = callback;
|
|
11
|
+
}
|
|
8
12
|
export function registerLtAuthPlugins(plugins) {
|
|
9
13
|
_ltAuthPluginRegistry = [..._ltAuthPluginRegistry, ...plugins];
|
|
14
|
+
if (_resetAuthClientCallback) {
|
|
15
|
+
_resetAuthClientCallback();
|
|
16
|
+
}
|
|
10
17
|
}
|
|
11
18
|
export function getLtAuthPluginRegistry() {
|
|
12
19
|
return _ltAuthPluginRegistry;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { attemptLtJwtSwitch, createLtAuthFetch, getLtApiBase, getLtAuthMode, getLtJwtToken, isLtAuthenticated, ltAuthFetch, setLtAuthMode, setLtJwtToken, } from "./auth-state.js";
|
|
2
|
-
export { clearLtAuthPluginRegistry, createLtAuthClient, getLtAuthPluginRegistry, registerLtAuthPlugins, type LtAuthClient, } from "./auth-client.js";
|
|
2
|
+
export { clearLtAuthPluginRegistry, createLtAuthClient, getLtAuthPluginRegistry, registerLtAuthPlugins, setResetAuthClientCallback, type LtAuthClient, } from "./auth-client.js";
|