palbase 0.5.2 → 0.6.2
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/ai/index.js +2 -2
- package/dist/backend/engine.js +2 -2
- package/dist/backend/env.js +1 -1
- package/dist/backend/index.js +7 -7
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/{QHPZF7VM.js → 2RG3I7LX.js} +2 -2
- package/dist/chunks/{LHLMCQKI.js → 53FS342F.js} +2 -2
- package/dist/chunks/{MYNCDAKM.js → A3CDCPXX.js} +1 -1
- package/dist/chunks/{QHJ4OPPI.js → A76UZBAF.js} +2 -2
- package/dist/chunks/{FNUO6DSY.js → AD5LBZAB.js} +1 -1
- package/dist/chunks/{4ZVJ62A3.js → AYY4J3B2.js} +1 -1
- package/dist/chunks/{K2LVOEW3.js → DRGYTL6T.js} +2 -2
- package/dist/chunks/{ZJOO2XZ2.js → DRTZ33XF.js} +2 -2
- package/dist/chunks/{6I6CETZY.js → GVFZM4BI.js} +3 -3
- package/dist/chunks/{JHQDWDV3.js → IVEAUFGE.js} +2 -2
- package/dist/chunks/{HLYQRT7O.js → IYCW6PWG.js} +2 -2
- package/dist/chunks/KL7FIRII.js +2 -0
- package/dist/chunks/{TPBWIRHS.js → KLANM6M6.js} +1 -1
- package/dist/chunks/{NQA7ZLGD.js → SUX2BJG4.js} +1 -1
- package/dist/chunks/{5G3URQAW.js → SXH5AIQX.js} +2 -2
- package/dist/chunks/{XRW7YOUQ.js → U4OZ4HOF.js} +2 -2
- package/dist/chunks/{EDVRVUCJ.js → VP7V7YRH.js} +2 -2
- package/dist/cli.js +2 -2
- package/dist/refuse/ai.js +1 -1
- package/dist/refuse/backend.js +1 -1
- package/dist/refuse/server.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/testing.js +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/palbe.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/ssr.js +2 -0
- package/dist/web/vite.js +2 -2
- package/package.json +6 -2
- package/types/web/src/client.d.ts +3 -1
- package/types/web/src/index.d.ts +1 -1
- package/types/web/src/session.d.ts +11 -0
- package/types/web/src/ssr.d.ts +86 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { User } from './auth.js';
|
|
2
|
+
import { type ClientOptions, type PalbaseClient } from './client.js';
|
|
3
|
+
import type { SessionStore } from './session.js';
|
|
4
|
+
/** A cookie's attributes, as Next.js's cookies().set and the cookie package name them. */
|
|
5
|
+
export interface CookieOptions {
|
|
6
|
+
path?: string;
|
|
7
|
+
domain?: string;
|
|
8
|
+
maxAge?: number;
|
|
9
|
+
expires?: Date;
|
|
10
|
+
sameSite?: 'lax' | 'strict' | 'none';
|
|
11
|
+
secure?: boolean;
|
|
12
|
+
httpOnly?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The request's cookies, and — where the server can write the response's — a
|
|
16
|
+
* way to write them. An answer that writes a session's cookies is one user's:
|
|
17
|
+
* setAll is given the headers that keep any cache between the server and the
|
|
18
|
+
* browser from keeping it and handing it to someone else — set them on the
|
|
19
|
+
* response with the cookies.
|
|
20
|
+
*/
|
|
21
|
+
export interface CookieMethods {
|
|
22
|
+
getAll(): {
|
|
23
|
+
name: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[] | Promise<{
|
|
26
|
+
name: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}[]>;
|
|
29
|
+
setAll?(cookies: {
|
|
30
|
+
name: string;
|
|
31
|
+
value: string;
|
|
32
|
+
options: CookieOptions;
|
|
33
|
+
}[], headers: Record<string, string>): void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/** What an answer that writes a session's cookies is sent with: kept by no cache. */
|
|
36
|
+
export declare const NO_STORE_HEADERS: Readonly<Record<string, string>>;
|
|
37
|
+
/**
|
|
38
|
+
* What the session's cookies are written with unless the app says: the whole
|
|
39
|
+
* site; sent when a link from elsewhere opens it (a sign-in link); over https
|
|
40
|
+
* alone (a page served on http — a developer's computer — says secure: false,
|
|
41
|
+
* and the browser's client says it of a page on http itself); kept as long as
|
|
42
|
+
* a browser keeps a cookie (400 days — the session itself ends when its
|
|
43
|
+
* refresh token does); readable by the page, as the browser client reads it.
|
|
44
|
+
*/
|
|
45
|
+
export declare const SESSION_COOKIE_OPTIONS: CookieOptions;
|
|
46
|
+
/** The session's cookie for the project the publishable key is of: pb-<ref>-session (with .0, .1, … when it is long). */
|
|
47
|
+
export declare function sessionCookieName(publishableKey: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* The session in cookies named `name` (one, or numbered parts): read from
|
|
50
|
+
* getAll on every load, written with setAll — or not at all where there is
|
|
51
|
+
* none to write with.
|
|
52
|
+
*/
|
|
53
|
+
export declare function cookieSessionStore(name: string, cookies: CookieMethods, options?: CookieOptions, shared?: boolean): SessionStore;
|
|
54
|
+
type SsrOptions = Omit<ClientOptions, 'storage'> & {
|
|
55
|
+
cookieOptions?: CookieOptions;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A server's client for one request, its session in the request's cookies:
|
|
59
|
+
* it renews the session before a call that finds it about to lapse when it
|
|
60
|
+
* can write the response's cookies (setAll), and never when it cannot.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createServerClient(opts: SsrOptions & {
|
|
63
|
+
cookies: CookieMethods;
|
|
64
|
+
}): PalbaseClient;
|
|
65
|
+
/** The page's cookies (document.cookie). */
|
|
66
|
+
export declare function documentCookies(): CookieMethods;
|
|
67
|
+
/**
|
|
68
|
+
* The browser's client, its session in the page's cookies — where the
|
|
69
|
+
* server's pages read it. Renewed behind the call, as any browser client's,
|
|
70
|
+
* one tab at a time.
|
|
71
|
+
*/
|
|
72
|
+
export declare function createBrowserClient(opts: SsrOptions): PalbaseClient;
|
|
73
|
+
/**
|
|
74
|
+
* Who is signed in, as auth says — a server's middleware calls it on the way
|
|
75
|
+
* in, with a client that writes the response's cookies: the session is
|
|
76
|
+
* renewed first when it has little left (a renewal that could not be made
|
|
77
|
+
* keeps it while its token works), then auth is asked whose its token is.
|
|
78
|
+
* Null when no one is signed in, the session is over, or auth does not take
|
|
79
|
+
* the token: a cookie the browser could have written is never taken at its
|
|
80
|
+
* word. Asking writes nothing back: only a renewal writes the session, so an
|
|
81
|
+
* answer never puts back the session its request carried over one the
|
|
82
|
+
* browser renewed meanwhile (whose old refresh token, used again later, would
|
|
83
|
+
* end the session).
|
|
84
|
+
*/
|
|
85
|
+
export declare function keepSession(pb: PalbaseClient): Promise<User | null>;
|
|
86
|
+
export {};
|