@luxdb/sdk 2.1.0 → 2.2.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/cjs/ssr.js +6 -3
- package/dist/esm/ssr.js +6 -3
- package/dist/types/ssr.d.ts +7 -2
- package/package.json +1 -1
package/dist/cjs/ssr.js
CHANGED
|
@@ -3,21 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createServerClient = createServerClient;
|
|
4
4
|
const project_1 = require("./project");
|
|
5
5
|
const DEFAULT_COOKIE = 'lux-auth-session';
|
|
6
|
-
function createServerClient(url, key, options) {
|
|
6
|
+
function createServerClient(url, key, options = {}) {
|
|
7
7
|
const storageKey = options.auth?.storageKey ?? DEFAULT_COOKIE;
|
|
8
8
|
const cookieOptions = options.auth?.cookieOptions ?? {
|
|
9
9
|
path: '/',
|
|
10
10
|
sameSite: 'lax',
|
|
11
11
|
};
|
|
12
12
|
const { cookieOptions: _cookieOptions, ...authOptions } = options.auth ?? {};
|
|
13
|
+
// With cookies -> cookie-backed session (SSR). Without -> stateless backend
|
|
14
|
+
// client: no session storage, nothing to persist.
|
|
15
|
+
const hasCookies = options.cookies !== undefined;
|
|
13
16
|
return (0, project_1.createClient)(url, key, {
|
|
14
17
|
fetch: options.fetch,
|
|
15
18
|
auth: {
|
|
16
|
-
persistSession:
|
|
19
|
+
persistSession: hasCookies,
|
|
17
20
|
autoRefreshToken: false,
|
|
18
21
|
...authOptions,
|
|
19
22
|
storageKey,
|
|
20
|
-
storage: cookieStorage(options.cookies, cookieOptions),
|
|
23
|
+
storage: hasCookies ? cookieStorage(options.cookies, cookieOptions) : null,
|
|
21
24
|
},
|
|
22
25
|
});
|
|
23
26
|
}
|
package/dist/esm/ssr.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { createClient } from './project.js';
|
|
2
2
|
const DEFAULT_COOKIE = 'lux-auth-session';
|
|
3
|
-
export function createServerClient(url, key, options) {
|
|
3
|
+
export function createServerClient(url, key, options = {}) {
|
|
4
4
|
const storageKey = options.auth?.storageKey ?? DEFAULT_COOKIE;
|
|
5
5
|
const cookieOptions = options.auth?.cookieOptions ?? {
|
|
6
6
|
path: '/',
|
|
7
7
|
sameSite: 'lax',
|
|
8
8
|
};
|
|
9
9
|
const { cookieOptions: _cookieOptions, ...authOptions } = options.auth ?? {};
|
|
10
|
+
// With cookies -> cookie-backed session (SSR). Without -> stateless backend
|
|
11
|
+
// client: no session storage, nothing to persist.
|
|
12
|
+
const hasCookies = options.cookies !== undefined;
|
|
10
13
|
return createClient(url, key, {
|
|
11
14
|
fetch: options.fetch,
|
|
12
15
|
auth: {
|
|
13
|
-
persistSession:
|
|
16
|
+
persistSession: hasCookies,
|
|
14
17
|
autoRefreshToken: false,
|
|
15
18
|
...authOptions,
|
|
16
19
|
storageKey,
|
|
17
|
-
storage: cookieStorage(options.cookies, cookieOptions),
|
|
20
|
+
storage: hasCookies ? cookieStorage(options.cookies, cookieOptions) : null,
|
|
18
21
|
},
|
|
19
22
|
});
|
|
20
23
|
}
|
package/dist/types/ssr.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export interface LuxServerClientOptions extends Omit<LuxProjectOptions, 'url' |
|
|
|
17
17
|
auth?: Omit<NonNullable<LuxProjectOptions['auth']>, 'storage'> & {
|
|
18
18
|
cookieOptions?: LuxCookieOptions;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Cookie adapter for SSR session persistence (Next/SvelteKit/etc). Omit it
|
|
22
|
+
* for a stateless backend client (secret key, or `setSession` per request):
|
|
23
|
+
* `createServerClient(url, key)` then works with no cookie plumbing.
|
|
24
|
+
*/
|
|
25
|
+
cookies?: LuxCookieMethods;
|
|
21
26
|
}
|
|
22
|
-
export declare function createServerClient(url: string, key: string, options
|
|
27
|
+
export declare function createServerClient(url: string, key: string, options?: LuxServerClientOptions): import("./project").LuxProjectClient;
|
package/package.json
CHANGED