@supatype/ssr 0.8.0 → 0.9.1
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +10 -8
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +28 -0
- package/README.md +46 -6
- package/dist/cookie-parser.d.ts.map +1 -1
- package/dist/cookie-parser.js +8 -29
- package/dist/cookie-parser.js.map +1 -1
- package/dist/jwt-claims.d.ts +13 -0
- package/dist/jwt-claims.d.ts.map +1 -0
- package/dist/jwt-claims.js +30 -0
- package/dist/jwt-claims.js.map +1 -0
- package/dist/next.d.ts +35 -0
- package/dist/next.d.ts.map +1 -0
- package/dist/next.js +135 -0
- package/dist/next.js.map +1 -0
- package/dist/server-client.d.ts +8 -1
- package/dist/server-client.d.ts.map +1 -1
- package/dist/server-client.js +16 -15
- package/dist/server-client.js.map +1 -1
- package/dist/server-env.d.ts +20 -0
- package/dist/server-env.d.ts.map +1 -0
- package/dist/server-env.js +25 -0
- package/dist/server-env.js.map +1 -0
- package/package.json +7 -3
- package/src/cookie-parser.ts +7 -28
- package/src/jwt-claims.ts +30 -0
- package/src/next.ts +149 -0
- package/src/server-client.ts +28 -4
- package/src/server-env.ts +26 -0
- package/tests/next.test.ts +184 -0
- package/tests/server-client-env.test.ts +108 -0
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @supatype/ssr@0.
|
|
3
|
-
> vitest run
|
|
2
|
+
> @supatype/ssr@0.9.1 test /home/runner/work/supatype/supatype/packages/ssr
|
|
3
|
+
> vitest run --maxWorkers=50%
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
[1m[46m RUN [49m[22m [36mv4.0.18 [39m[90m/home/runner/work/supatype/supatype/packages/ssr[39m
|
|
7
7
|
|
|
8
|
-
[32m✓[39m tests/
|
|
9
|
-
[32m✓[39m tests/server-client.test.ts [2m([22m[
|
|
8
|
+
[32m✓[39m tests/next.test.ts [2m([22m[2m24 tests[22m[2m)[22m[32m 112[2mms[22m[39m
|
|
9
|
+
[32m✓[39m tests/server-client-env.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 289[2mms[22m[39m
|
|
10
|
+
[32m✓[39m tests/server-client.test.ts [2m([22m[2m9 tests[22m[2m)[22m[33m 417[2mms[22m[39m
|
|
11
|
+
[32m✓[39m tests/cookie-parser.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 29[2mms[22m[39m
|
|
10
12
|
|
|
11
|
-
[2m Test Files [22m [1m[
|
|
12
|
-
[2m Tests [22m [1m[
|
|
13
|
-
[2m Start at [22m
|
|
14
|
-
[2m Duration [22m
|
|
13
|
+
[2m Test Files [22m [1m[32m4 passed[39m[22m[90m (4)[39m
|
|
14
|
+
[2m Tests [22m [1m[32m42 passed[39m[22m[90m (42)[39m
|
|
15
|
+
[2m Start at [22m 09:14:27
|
|
16
|
+
[2m Duration [22m 4.92s[2m (transform 2.44s, setup 0ms, import 3.67s, tests 847ms, environment 3ms)[22m
|
|
15
17
|
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **next:** `@supatype/ssr/next` exports `GET` for `app/supatype-env.js/route.ts`. It answers
|
|
8
|
+
`window.__SUPATYPE_ENV__ = {"url":"...","anonKey":"..."};` from `SUPATYPE_URL` and
|
|
9
|
+
`SUPATYPE_ANON_KEY` as the running server has them, with the Supatype server's own body and headers
|
|
10
|
+
(`application/javascript; charset=utf-8`, `Cache-Control: no-cache`, `X-Content-Type-Options:
|
|
11
|
+
nosniff`). Switched off with `SUPATYPE_PUBLIC_ENV=false` (or `0`, `no`, `off`) it is 404
|
|
12
|
+
`no-store`. Misconfigured it is still 200, `no-store`, with
|
|
13
|
+
`window.__SUPATYPE_ENV__ = {"error":"..."};` naming every setting to fix and never echoing a key,
|
|
14
|
+
because a browser runs no script answered with an error status and tells the page nothing of
|
|
15
|
+
why; the client throws that reason on its first call. The faults: `SUPATYPE_ANON_KEY` or
|
|
16
|
+
`SUPATYPE_URL` unset (a page given only the key would fail for want of an address; with both
|
|
17
|
+
unset, or a service role key and no address, the reason names each fault on its own line, the
|
|
18
|
+
key's first, so one visit fixes them all), `SUPATYPE_PUBLIC_ENV` holding a word it cannot read
|
|
19
|
+
(the reason names the words it takes), or the anon key variable holding a service role token. No
|
|
20
|
+
service role value is ever read.
|
|
21
|
+
With `<Script src="/supatype-env.js" strategy="beforeInteractive" />`
|
|
22
|
+
in the root layout, one `next build` runs against any deployment. The route file writes
|
|
23
|
+
`export const dynamic = "force-dynamic"` itself, since Next's build does not recognize a
|
|
24
|
+
re-exported segment config.
|
|
25
|
+
* **server-client:** `createServerClient(options)`, and `undefined` for either of `url` and
|
|
26
|
+
`anonKey`, take them from `SUPATYPE_URL` and `SUPATYPE_ANON_KEY` in the server's environment,
|
|
27
|
+
read when the client is created, and where one is unset from `NEXT_PUBLIC_SUPATYPE_URL` or
|
|
28
|
+
`NEXT_PUBLIC_SUPATYPE_ANON_KEY`. `createServerClient(url, anonKey, options)` works as before.
|
package/README.md
CHANGED
|
@@ -21,13 +21,14 @@ import { createServerClient } from "@supatype/ssr"
|
|
|
21
21
|
import { cookies } from "next/headers"
|
|
22
22
|
import type { Database } from "@/types/database"
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// The address and anon key come from SUPATYPE_URL and SUPATYPE_ANON_KEY in the server's
|
|
25
|
+
// environment, read on each call, so the same build runs against whichever deployment it is
|
|
26
|
+
// started for. Pass them first, as createServerClient(url, anonKey, options), to use others.
|
|
26
27
|
|
|
27
28
|
// Server Components: no `setAll`, so the client never refreshes the session.
|
|
28
29
|
export async function createClient() {
|
|
29
30
|
const cookieStore = await cookies()
|
|
30
|
-
return createServerClient<Database>(
|
|
31
|
+
return createServerClient<Database>({
|
|
31
32
|
cookies: {
|
|
32
33
|
getAll() { return cookieStore.getAll() },
|
|
33
34
|
},
|
|
@@ -37,7 +38,7 @@ export async function createClient() {
|
|
|
37
38
|
// Route Handlers and Server Actions: a refreshed session goes back to the browser.
|
|
38
39
|
export async function createWritableClient() {
|
|
39
40
|
const cookieStore = await cookies()
|
|
40
|
-
return createServerClient<Database>(
|
|
41
|
+
return createServerClient<Database>({
|
|
41
42
|
cookies: {
|
|
42
43
|
getAll() { return cookieStore.getAll() },
|
|
43
44
|
setAll(cookiesToSet) {
|
|
@@ -72,6 +73,43 @@ const { data: { session } } = await supatype.auth.getSession()
|
|
|
72
73
|
// is: its access token may have expired, since that client never refreshes it.
|
|
73
74
|
```
|
|
74
75
|
|
|
76
|
+
### The browser client's values at run time (`@supatype/ssr/next`)
|
|
77
|
+
|
|
78
|
+
`next build` prerenders static pages without the deployment's values. Serve them to the page when
|
|
79
|
+
it loads instead, from the same two server variables, with a route and one line in the root layout:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// app/supatype-env.js/route.ts
|
|
83
|
+
export { GET } from "@supatype/ssr/next"
|
|
84
|
+
export const dynamic = "force-dynamic"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
// app/layout.tsx
|
|
89
|
+
import Script from "next/script"
|
|
90
|
+
|
|
91
|
+
// inside <body>, before anything else:
|
|
92
|
+
<Script src="/supatype-env.js" strategy="beforeInteractive" />
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Write the `dynamic` line in the route file itself: Next's build reads a route's segment config
|
|
96
|
+
from that file's own source and does not recognize a re-exported one. `GET` answers
|
|
97
|
+
`window.__SUPATYPE_ENV__ = {"url":"...","anonKey":"..."};` from `SUPATYPE_URL` and
|
|
98
|
+
`SUPATYPE_ANON_KEY` as the server has them on each request, with `Cache-Control: no-cache`, the same
|
|
99
|
+
body and headers the Supatype server gives its own `/supatype-env.js`. Switched off with
|
|
100
|
+
`SUPATYPE_PUBLIC_ENV=false` it answers 404 `no-store`. Misconfigured it still answers 200, with
|
|
101
|
+
`Cache-Control: no-store` and `window.__SUPATYPE_ENV__ = {"error":"..."};`, since a browser runs no
|
|
102
|
+
script answered with an error status and tells the page nothing of why. The browser client throws
|
|
103
|
+
that reason on its first call. It names every setting to fix, one line each and the key's first:
|
|
104
|
+
`SUPATYPE_ANON_KEY` or `SUPATYPE_URL` unset (both named when both are), `SUPATYPE_PUBLIC_ENV` set to
|
|
105
|
+
a word other than true/1/yes/on or false/0/no/off (blank counts as on), or the anon key variable
|
|
106
|
+
holding a service role token. No key is echoed, and no service role value is ever read.
|
|
107
|
+
|
|
108
|
+
The browser client, created with no `url` or `anonKey` (or with `NEXT_PUBLIC_` names left unset at
|
|
109
|
+
build time), reads `window.__SUPATYPE_ENV__` at its first request. A client created at module scope
|
|
110
|
+
does not throw while the build prerenders a page; its first request throws, naming what to set,
|
|
111
|
+
when neither the build nor the page supplied the values.
|
|
112
|
+
|
|
75
113
|
### Cookie adapter interface
|
|
76
114
|
|
|
77
115
|
`createServerClient` accepts any framework's cookie store via the `CookieAdapter` interface:
|
|
@@ -120,9 +158,11 @@ createServerClient(url, anonKey, {
|
|
|
120
158
|
|
|
121
159
|
## API
|
|
122
160
|
|
|
123
|
-
### `createServerClient<TDatabase>(url, anonKey, options)`
|
|
161
|
+
### `createServerClient<TDatabase>(url, anonKey, options)`, or `createServerClient<TDatabase>(options)`
|
|
124
162
|
|
|
125
|
-
|
|
163
|
+
`url` and `anonKey` default to `SUPATYPE_URL` and `SUPATYPE_ANON_KEY` from the server's environment
|
|
164
|
+
when left out, `undefined` or empty, and where one of those is unset to `NEXT_PUBLIC_SUPATYPE_URL` or
|
|
165
|
+
`NEXT_PUBLIC_SUPATYPE_ANON_KEY`. Returns a fully-typed `SupatypeClient` pre-loaded with the user's session from cookies. The returned client has the same API as the browser client, `.from()`, `.auth`, `.storage`, `.rpc()`, etc.
|
|
126
166
|
|
|
127
167
|
| Option | Type | Default | Description |
|
|
128
168
|
|--------|------|---------|-------------|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-parser.d.ts","sourceRoot":"","sources":["../src/cookie-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAQ,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"cookie-parser.d.ts","sourceRoot":"","sources":["../src/cookie-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAQ,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAG7C,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,OAAO,CAAA;AAEzC,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EAC/C,MAAM,GAAE,MAA8B,GACrC,OAAO,GAAG,IAAI,CAoBhB;AAsDD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,EAAE,MAAM,GAAE,MAA8B,GAAG,WAAW,CAc1G"}
|
package/dist/cookie-parser.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeBase64, isJsonObject, jwtClaims } from "./jwt-claims.js";
|
|
1
2
|
/** The prefix `@supatype/client` names its session cookie with: `st-auth-token`. */
|
|
2
3
|
export const DEFAULT_COOKIE_PREFIX = "st";
|
|
3
4
|
export function parseSessionFromCookies(cookies, prefix = DEFAULT_COOKIE_PREFIX) {
|
|
@@ -18,10 +19,6 @@ export function parseSessionFromCookies(cookies, prefix = DEFAULT_COOKIE_PREFIX)
|
|
|
18
19
|
}
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
21
|
-
/** True for a JSON object: not null, not an array. */
|
|
22
|
-
function isJsonObject(value) {
|
|
23
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
|
-
}
|
|
25
22
|
function parseSessionValue(value) {
|
|
26
23
|
try {
|
|
27
24
|
return normalizeSession(JSON.parse(decodeURIComponent(value)));
|
|
@@ -33,16 +30,6 @@ function parseSessionValue(value) {
|
|
|
33
30
|
catch { /* not base64 JSON */ }
|
|
34
31
|
return null;
|
|
35
32
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Base64 or base64url text decoded as UTF-8, with `atob` and `TextDecoder` rather than Node's
|
|
38
|
-
* `Buffer`: the server client also runs on edge runtimes, which have no `Buffer`. Throws on input
|
|
39
|
-
* that is not base64.
|
|
40
|
-
*/
|
|
41
|
-
function decodeBase64(text) {
|
|
42
|
-
const standard = text.replace(/-/g, "+").replace(/_/g, "/");
|
|
43
|
-
const binary = atob(standard + "=".repeat((4 - (standard.length % 4)) % 4));
|
|
44
|
-
return new TextDecoder().decode(Uint8Array.from(binary, (c) => c.charCodeAt(0)));
|
|
45
|
-
}
|
|
46
33
|
/**
|
|
47
34
|
* The session a cookie holds. One whose access token has expired is kept when it carries a refresh
|
|
48
35
|
* token: the first request the client makes refreshes it, and the server client writes the new
|
|
@@ -66,22 +53,14 @@ function normalizeSession(r) {
|
|
|
66
53
|
};
|
|
67
54
|
}
|
|
68
55
|
function isJwtExpired(token) {
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
// A token that is not a JWT, or whose payload is not an object, reads as expired.
|
|
57
|
+
const payload = jwtClaims(token);
|
|
58
|
+
if (payload === null)
|
|
71
59
|
return true;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return true;
|
|
77
|
-
const exp = typeof payload["exp"] === "number" ? payload["exp"] : null;
|
|
78
|
-
if (exp === null)
|
|
79
|
-
return false;
|
|
80
|
-
return Date.now() / 1000 > exp;
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
60
|
+
const exp = typeof payload["exp"] === "number" ? payload["exp"] : null;
|
|
61
|
+
if (exp === null)
|
|
62
|
+
return false;
|
|
63
|
+
return Date.now() / 1000 > exp;
|
|
85
64
|
}
|
|
86
65
|
function normalizeUser(raw) {
|
|
87
66
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookie-parser.js","sourceRoot":"","sources":["../src/cookie-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cookie-parser.js","sourceRoot":"","sources":["../src/cookie-parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEvE,oFAAoF;AACpF,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAA;AAEzC,MAAM,UAAU,uBAAuB,CACrC,OAA+C,EAC/C,SAAiB,qBAAqB;IAEtC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAC/B,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,IAAI,KAAK,GAAG,MAAM,aAAa;QACjC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CACtE,CAAA;IACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAExC,gEAAgE;IAChE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACvB,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,MAAM,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACxD,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK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I,CAAC,SAAS;KAC3B,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a JWT's claims without verifying it, in a way every runtime the server client reaches
|
|
3
|
+
* supports: `atob` and `TextDecoder` rather than Node's `Buffer`, which edge runtimes do not have.
|
|
4
|
+
* Shared by the cookie parser (a session's expiry) and the Next.js route (a service role token
|
|
5
|
+
* where the anon key belongs).
|
|
6
|
+
*/
|
|
7
|
+
/** True for a JSON object: not null, not an array. */
|
|
8
|
+
export declare function isJsonObject(value: unknown): value is Record<string, unknown>;
|
|
9
|
+
/** Base64 or base64url text decoded as UTF-8. Throws on input that is not base64. */
|
|
10
|
+
export declare function decodeBase64(text: string): string;
|
|
11
|
+
/** The payload of a three-part JWT, or null for anything else. Not verified. */
|
|
12
|
+
export declare function jwtClaims(token: string): Record<string, unknown> | null;
|
|
13
|
+
//# sourceMappingURL=jwt-claims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-claims.d.ts","sourceRoot":"","sources":["../src/jwt-claims.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE7E;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CASvE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a JWT's claims without verifying it, in a way every runtime the server client reaches
|
|
3
|
+
* supports: `atob` and `TextDecoder` rather than Node's `Buffer`, which edge runtimes do not have.
|
|
4
|
+
* Shared by the cookie parser (a session's expiry) and the Next.js route (a service role token
|
|
5
|
+
* where the anon key belongs).
|
|
6
|
+
*/
|
|
7
|
+
/** True for a JSON object: not null, not an array. */
|
|
8
|
+
export function isJsonObject(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
/** Base64 or base64url text decoded as UTF-8. Throws on input that is not base64. */
|
|
12
|
+
export function decodeBase64(text) {
|
|
13
|
+
const standard = text.replace(/-/g, "+").replace(/_/g, "/");
|
|
14
|
+
const binary = atob(standard + "=".repeat((4 - (standard.length % 4)) % 4));
|
|
15
|
+
return new TextDecoder().decode(Uint8Array.from(binary, (c) => c.charCodeAt(0)));
|
|
16
|
+
}
|
|
17
|
+
/** The payload of a three-part JWT, or null for anything else. Not verified. */
|
|
18
|
+
export function jwtClaims(token) {
|
|
19
|
+
const payload = token.split(".");
|
|
20
|
+
if (payload.length !== 3 || payload[1] === undefined)
|
|
21
|
+
return null;
|
|
22
|
+
try {
|
|
23
|
+
const claims = JSON.parse(decodeBase64(payload[1]));
|
|
24
|
+
return isJsonObject(claims) ? claims : null;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=jwt-claims.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-claims.js","sourceRoot":"","sources":["../src/jwt-claims.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sDAAsD;AACtD,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC3E,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAClF,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAChC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS;QAAE,OAAO,IAAI,CAAA;IACjE,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC5D,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
package/dist/next.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/supatype-env.js` for a Next.js app: the route that gives a page the deployment's API address
|
|
3
|
+
* and anon key when it loads, so one `next build` runs against any deployment.
|
|
4
|
+
*
|
|
5
|
+
* `next build` prerenders the static pages without the deployment's values, and the client then
|
|
6
|
+
* reads them from `window.__SUPATYPE_ENV__` at its first request. This route sets that global from
|
|
7
|
+
* `SUPATYPE_URL` and `SUPATYPE_ANON_KEY` as the running server has them, with the same body,
|
|
8
|
+
* headers and misconfigured answer as the Supatype server's own `/supatype-env.js`. Put it at
|
|
9
|
+
* `app/supatype-env.js/route.ts`:
|
|
10
|
+
*
|
|
11
|
+
* export { GET } from "@supatype/ssr/next"
|
|
12
|
+
* export const dynamic = "force-dynamic"
|
|
13
|
+
*
|
|
14
|
+
* The `dynamic` line is written in the route file itself: Next's build reads a route's segment
|
|
15
|
+
* config from that file's own source, and warns that it cannot recognize a re-exported one and
|
|
16
|
+
* uses the default instead. Next 15 already renders a `GET` handler per request by default; Next 14
|
|
17
|
+
* prerendered one, which would bake the build machine's values into a static file. Then load it
|
|
18
|
+
* before the app in the root layout:
|
|
19
|
+
*
|
|
20
|
+
* <Script src="/supatype-env.js" strategy="beforeInteractive" />
|
|
21
|
+
*
|
|
22
|
+
* The anon key is not a secret: every browser that loads the app holds it, and row-level security
|
|
23
|
+
* protects the data. The service role key is never read here, and an anon key variable holding a
|
|
24
|
+
* service role token is refused rather than published.
|
|
25
|
+
*/
|
|
26
|
+
/** Never prerendered. Exported for tests and tools; the route file writes its own (see above). */
|
|
27
|
+
export declare const dynamic = "force-dynamic";
|
|
28
|
+
/**
|
|
29
|
+
* `GET /supatype-env.js`: the script setting `window.__SUPATYPE_ENV__`. Misconfigured, it is still
|
|
30
|
+
* 200 and sets only `error`, the reason, because a browser runs no script answered with an error
|
|
31
|
+
* status and tells the page nothing of why: this is the one way the client can name the fault on
|
|
32
|
+
* its first call. Switched off it is 404, as the Supatype server answers.
|
|
33
|
+
*/
|
|
34
|
+
export declare function GET(): Response;
|
|
35
|
+
//# sourceMappingURL=next.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../src/next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,kGAAkG;AAClG,eAAO,MAAM,OAAO,kBAAkB,CAAA;AActC;;;;;GAKG;AACH,wBAAgB,GAAG,IAAI,QAAQ,CAM9B"}
|
package/dist/next.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/supatype-env.js` for a Next.js app: the route that gives a page the deployment's API address
|
|
3
|
+
* and anon key when it loads, so one `next build` runs against any deployment.
|
|
4
|
+
*
|
|
5
|
+
* `next build` prerenders the static pages without the deployment's values, and the client then
|
|
6
|
+
* reads them from `window.__SUPATYPE_ENV__` at its first request. This route sets that global from
|
|
7
|
+
* `SUPATYPE_URL` and `SUPATYPE_ANON_KEY` as the running server has them, with the same body,
|
|
8
|
+
* headers and misconfigured answer as the Supatype server's own `/supatype-env.js`. Put it at
|
|
9
|
+
* `app/supatype-env.js/route.ts`:
|
|
10
|
+
*
|
|
11
|
+
* export { GET } from "@supatype/ssr/next"
|
|
12
|
+
* export const dynamic = "force-dynamic"
|
|
13
|
+
*
|
|
14
|
+
* The `dynamic` line is written in the route file itself: Next's build reads a route's segment
|
|
15
|
+
* config from that file's own source, and warns that it cannot recognize a re-exported one and
|
|
16
|
+
* uses the default instead. Next 15 already renders a `GET` handler per request by default; Next 14
|
|
17
|
+
* prerendered one, which would bake the build machine's values into a static file. Then load it
|
|
18
|
+
* before the app in the root layout:
|
|
19
|
+
*
|
|
20
|
+
* <Script src="/supatype-env.js" strategy="beforeInteractive" />
|
|
21
|
+
*
|
|
22
|
+
* The anon key is not a secret: every browser that loads the app holds it, and row-level security
|
|
23
|
+
* protects the data. The service role key is never read here, and an anon key variable holding a
|
|
24
|
+
* service role token is refused rather than published.
|
|
25
|
+
*/
|
|
26
|
+
import { jwtClaims } from "./jwt-claims.js";
|
|
27
|
+
import { SERVER_ANON_KEY_ENV, SERVER_URL_ENV, serverEnv } from "./server-env.js";
|
|
28
|
+
/** Never prerendered. Exported for tests and tools; the route file writes its own (see above). */
|
|
29
|
+
export const dynamic = "force-dynamic";
|
|
30
|
+
const PUBLIC_ENV_SWITCH = "SUPATYPE_PUBLIC_ENV";
|
|
31
|
+
const SCRIPT_GLOBAL = "window.__SUPATYPE_ENV__";
|
|
32
|
+
/** `<`, `>`, `&` and the two JavaScript line separators, escaped in the body as Go's JSON does. */
|
|
33
|
+
const SCRIPT_UNSAFE = new Set([0x3c, 0x3e, 0x26, 0x2028, 0x2029]);
|
|
34
|
+
/**
|
|
35
|
+
* `GET /supatype-env.js`: the script setting `window.__SUPATYPE_ENV__`. Misconfigured, it is still
|
|
36
|
+
* 200 and sets only `error`, the reason, because a browser runs no script answered with an error
|
|
37
|
+
* status and tells the page nothing of why: this is the one way the client can name the fault on
|
|
38
|
+
* its first call. Switched off it is 404, as the Supatype server answers.
|
|
39
|
+
*/
|
|
40
|
+
export function GET() {
|
|
41
|
+
const env = readPublicEnv();
|
|
42
|
+
if (env === "off")
|
|
43
|
+
return notFound();
|
|
44
|
+
// A reason is kept by nothing, so the fixed configuration is read on the next load. Values are
|
|
45
|
+
// revalidated on every load: they change when the deployment's configuration does.
|
|
46
|
+
return script(env, "error" in env ? "no-store" : "no-cache");
|
|
47
|
+
}
|
|
48
|
+
/** The values to serve, read from the environment now, or why there are none. */
|
|
49
|
+
function readPublicEnv() {
|
|
50
|
+
const enabled = publicEnvSwitch(serverEnv(PUBLIC_ENV_SWITCH));
|
|
51
|
+
if (enabled === false)
|
|
52
|
+
return "off";
|
|
53
|
+
// A word it cannot read is a fault to fix, not a choice to turn the route off.
|
|
54
|
+
if (enabled !== true)
|
|
55
|
+
return { error: enabled.invalid };
|
|
56
|
+
// Both, or neither: a page given only the key fails at its first request for want of an address,
|
|
57
|
+
// and the reason naming the variables says why, where the deployment is configured. Every fault
|
|
58
|
+
// is named in one reason, one per line and the key's first, so a single visit fixes them all.
|
|
59
|
+
const url = publicUrl(serverEnv(SERVER_URL_ENV));
|
|
60
|
+
const anonKey = serverEnv(SERVER_ANON_KEY_ENV);
|
|
61
|
+
const keyFault = anonKeyFault(anonKey);
|
|
62
|
+
const urlFault = url === undefined ? notSet(SERVER_URL_ENV) : undefined;
|
|
63
|
+
if (url === undefined || anonKey === undefined || keyFault !== undefined) {
|
|
64
|
+
const faults = [keyFault, urlFault].filter((fault) => fault !== undefined);
|
|
65
|
+
return { error: faults.join("\n") };
|
|
66
|
+
}
|
|
67
|
+
return { url, anonKey };
|
|
68
|
+
}
|
|
69
|
+
/** Why the anon key variable cannot be served, or undefined when it can. */
|
|
70
|
+
function anonKeyFault(anonKey) {
|
|
71
|
+
if (anonKey === undefined)
|
|
72
|
+
return notSet(SERVER_ANON_KEY_ENV);
|
|
73
|
+
if (jwtClaims(anonKey)?.["role"] !== "service_role")
|
|
74
|
+
return undefined;
|
|
75
|
+
return (`public env unavailable: ${SERVER_ANON_KEY_ENV} holds a service_role token, which must never ` +
|
|
76
|
+
"reach a browser. Set it to the project's anon key.");
|
|
77
|
+
}
|
|
78
|
+
/** The reason line for a variable the server does not have, as the Supatype server words it. */
|
|
79
|
+
function notSet(name) {
|
|
80
|
+
return `public env unavailable: ${name} is not set on this server`;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* `SUPATYPE_PUBLIC_ENV` as the server reads it: on when blank or 1, true, yes or on; off for 0, false,
|
|
84
|
+
* no or off. Any other word stops the server from starting; here, with no start to stop, the route
|
|
85
|
+
* is a reason naming the variable and the words it takes.
|
|
86
|
+
*/
|
|
87
|
+
function publicEnvSwitch(raw) {
|
|
88
|
+
const value = (raw ?? "").toLowerCase();
|
|
89
|
+
if (["", "1", "true", "yes", "on"].includes(value))
|
|
90
|
+
return true;
|
|
91
|
+
if (["0", "false", "no", "off"].includes(value))
|
|
92
|
+
return false;
|
|
93
|
+
return {
|
|
94
|
+
invalid: `public env unavailable: ${PUBLIC_ENV_SWITCH}=${JSON.stringify(raw)} is not a switch value. Use ` +
|
|
95
|
+
"true, 1, yes or on (or leave it blank) to serve it, and false, 0, no or off to turn it off.",
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** The API root, as the server gives it: no trailing slash, no auth service mount. */
|
|
99
|
+
function publicUrl(raw) {
|
|
100
|
+
const trimmed = raw?.replace(/\/+$/, "").replace(/\/auth\/v1$/, "");
|
|
101
|
+
return trimmed === undefined || trimmed === "" ? undefined : trimmed;
|
|
102
|
+
}
|
|
103
|
+
/** JSON that cannot close the script element or end the statement early. */
|
|
104
|
+
function escapeForScript(json) {
|
|
105
|
+
let out = "";
|
|
106
|
+
for (const ch of json) {
|
|
107
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
108
|
+
out += SCRIPT_UNSAFE.has(code) ? `\\u${code.toString(16).padStart(4, "0")}` : ch;
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
/** The statement setting `window.__SUPATYPE_ENV__` to `doc`, with the server's headers. */
|
|
113
|
+
function script(doc, cacheControl) {
|
|
114
|
+
const body = `${SCRIPT_GLOBAL} = ${escapeForScript(JSON.stringify(doc))};\n`;
|
|
115
|
+
return new Response(body, {
|
|
116
|
+
status: 200,
|
|
117
|
+
headers: {
|
|
118
|
+
"Content-Type": "application/javascript; charset=utf-8",
|
|
119
|
+
"Cache-Control": cacheControl,
|
|
120
|
+
"X-Content-Type-Options": "nosniff",
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** A 404 nothing keeps, so switching the route back on is seen at once, as the server answers. */
|
|
125
|
+
function notFound() {
|
|
126
|
+
return new Response("404 page not found\n", {
|
|
127
|
+
status: 404,
|
|
128
|
+
headers: {
|
|
129
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
130
|
+
"Cache-Control": "no-store",
|
|
131
|
+
"X-Content-Type-Options": "nosniff",
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=next.js.map
|
package/dist/next.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.js","sourceRoot":"","sources":["../src/next.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,SAAS,EAAE,MA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G,SAAS,QAAQ;IACf,OAAO,IAAI,QAAQ,CAAC,sBAAsB,EAAE;QAC1C,MAAM,EAAE,GAAG;QACX,OAAO,EAAE;YACP,cAAc,EAAE,2BAA2B;YAC3C,eAAe,EAAE,UAAU;YAC3B,wBAAwB,EAAE,SAAS;SACpC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/server-client.d.ts
CHANGED
|
@@ -11,6 +11,13 @@ import type { ServerClientOptions } from "./types.js";
|
|
|
11
11
|
* Without `setAll` (a Server Component) it never refreshes: an expired access token is sent as it
|
|
12
12
|
* is and refused. A refresh there would spend the browser's refresh token and return one the
|
|
13
13
|
* browser never receives, so the browser's own next refresh would be refused and sign it out.
|
|
14
|
+
*
|
|
15
|
+
* The address and anon key default to `SUPATYPE_URL` and `SUPATYPE_ANON_KEY` from the server's
|
|
16
|
+
* environment, read now: pass only the options, or `undefined` for either. These are the same two
|
|
17
|
+
* variables `@supatype/ssr/next` serves to the page. Where one is unset, `NEXT_PUBLIC_SUPATYPE_URL`
|
|
18
|
+
* or `NEXT_PUBLIC_SUPATYPE_ANON_KEY` is used instead. With none given or set, the client's first
|
|
19
|
+
* request throws the error naming them.
|
|
14
20
|
*/
|
|
15
|
-
export declare function createServerClient<TDatabase extends AnyDatabase = AnyDatabase>(
|
|
21
|
+
export declare function createServerClient<TDatabase extends AnyDatabase = AnyDatabase>(options: ServerClientOptions): SupatypeClient<TDatabase>;
|
|
22
|
+
export declare function createServerClient<TDatabase extends AnyDatabase = AnyDatabase>(url: string | undefined, anonKey: string | undefined, options: ServerClientOptions): SupatypeClient<TDatabase>;
|
|
16
23
|
//# sourceMappingURL=server-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-client.d.ts","sourceRoot":"","sources":["../src/server-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"server-client.d.ts","sourceRoot":"","sources":["../src/server-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnE,OAAO,KAAK,EAAiB,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEpE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,SAAS,WAAW,GAAG,WAAW,EAC5E,OAAO,EAAE,mBAAmB,GAC3B,cAAc,CAAC,SAAS,CAAC,CAAA;AAC5B,wBAAgB,kBAAkB,CAAC,SAAS,SAAS,WAAW,GAAG,WAAW,EAC5E,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,mBAAmB,GAC3B,cAAc,CAAC,SAAS,CAAC,CAAA"}
|
package/dist/server-client.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { createClient } from "@supatype/client";
|
|
2
2
|
import { DEFAULT_COOKIE_PREFIX, parseSessionFromCookies, sessionCookie } from "./cookie-parser.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* It keeps no session of its own and runs no refresh timer: the cookie is the only store, and the
|
|
7
|
-
* client lives as long as the request. With `setAll`, a refresh happens only when a request it
|
|
8
|
-
* makes finds the access token expired, and the rotated session goes back to the browser through
|
|
9
|
-
* `setAll`, so the browser holds the new refresh token rather than the one the refresh just spent.
|
|
10
|
-
*
|
|
11
|
-
* Without `setAll` (a Server Component) it never refreshes: an expired access token is sent as it
|
|
12
|
-
* is and refused. A refresh there would spend the browser's refresh token and return one the
|
|
13
|
-
* browser never receives, so the browser's own next refresh would be refused and sign it out.
|
|
14
|
-
*/
|
|
15
|
-
export function createServerClient(url, anonKey, options) {
|
|
3
|
+
import { SERVER_ANON_KEY_NAMES, SERVER_URL_NAMES, serverEnv } from "./server-env.js";
|
|
4
|
+
export function createServerClient(...args) {
|
|
5
|
+
const [url, anonKey, options] = args.length === 1 ? [undefined, undefined, args[0]] : args;
|
|
16
6
|
const prefix = options.cookiePrefix ?? DEFAULT_COOKIE_PREFIX;
|
|
17
7
|
const session = parseSessionFromCookies(options.cookies.getAll(), prefix);
|
|
18
8
|
const client = createClient({
|
|
19
|
-
url,
|
|
20
|
-
anonKey,
|
|
9
|
+
url: givenOrServerEnv(url, SERVER_URL_NAMES),
|
|
10
|
+
anonKey: givenOrServerEnv(anonKey, SERVER_ANON_KEY_NAMES),
|
|
21
11
|
auth: {
|
|
22
12
|
persistSession: false,
|
|
23
13
|
autoRefreshToken: false,
|
|
@@ -29,6 +19,17 @@ export function createServerClient(url, anonKey, options) {
|
|
|
29
19
|
writeSessionChanges(client, options.cookies, prefix);
|
|
30
20
|
return client;
|
|
31
21
|
}
|
|
22
|
+
/** The value given, unless it is missing or blank, else the first of the server's `names` that is set. */
|
|
23
|
+
function givenOrServerEnv(given, names) {
|
|
24
|
+
if (given !== undefined && given.trim() !== "")
|
|
25
|
+
return given;
|
|
26
|
+
for (const name of names) {
|
|
27
|
+
const value = serverEnv(name);
|
|
28
|
+
if (value !== undefined)
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
32
33
|
/**
|
|
33
34
|
* Send every change to the client's session (a refresh, a sign-in, a sign-out) back to the browser
|
|
34
35
|
* through the adapter's `setAll`, so the next request reads the new tokens rather than the old ones.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-client.js","sourceRoot":"","sources":["../src/server-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"server-client.js","sourceRoot":"","sources":["../src/server-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,C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E;QAAE,OAAO,KAAK,CAAA;IAC5D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;QAC7B,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,KAAK,CAAA;IACvC,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,MAAiC,EACjC,OAAsB,EACtB,MAAc;IAEd,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;QAAE,OAAM;IACxC,gGAAgG;IAChG,IAAI,UAAU,GAAG,KAAK,CAAA;IACtB,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;QAC7C,IAAI,CAAC,UAAU;YAAE,OAAM;QACvB,IAAI,CAAC;YACH,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;QACjD,CAAC;QAAC,MAAM,CAAC;YACP,8FAA8F;YAC9F,4FAA4F;QAC9F,CAAC;IACH,CAAC,CAAC,CAAA;IACF,UAAU,GAAG,IAAI,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two variables a Next.js server (or any server-side code) reads the deployment's address and
|
|
3
|
+
* anon key from: `createServerClient`'s defaults, and the values `@supatype/ssr/next` serves to the
|
|
4
|
+
* page. They are read where the app runs, so one build serves whichever deployment it runs as. A
|
|
5
|
+
* `NEXT_PUBLIC_` name, fixed into the build, is only the server client's fallback.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SERVER_URL_ENV = "SUPATYPE_URL";
|
|
8
|
+
export declare const SERVER_ANON_KEY_ENV = "SUPATYPE_ANON_KEY";
|
|
9
|
+
/**
|
|
10
|
+
* Where `createServerClient` looks for each value: the server's own name first, read where the app
|
|
11
|
+
* runs, then the Next.js build-time name an app may already set. The route serves only the first.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SERVER_URL_NAMES: readonly ["SUPATYPE_URL", "NEXT_PUBLIC_SUPATYPE_URL"];
|
|
14
|
+
export declare const SERVER_ANON_KEY_NAMES: readonly ["SUPATYPE_ANON_KEY", "NEXT_PUBLIC_SUPATYPE_ANON_KEY"];
|
|
15
|
+
/**
|
|
16
|
+
* A variable from the server's environment, trimmed; undefined when unset or blank, and where there
|
|
17
|
+
* is no `process` at all. Read by name at call time, so no bundler can fix its build-time value in.
|
|
18
|
+
*/
|
|
19
|
+
export declare function serverEnv(name: string): string | undefined;
|
|
20
|
+
//# sourceMappingURL=server-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-env.d.ts","sourceRoot":"","sources":["../src/server-env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,cAAc,iBAAiB,CAAA;AAC5C,eAAO,MAAM,mBAAmB,sBAAsB,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,uDAAwD,CAAA;AACrF,eAAO,MAAM,qBAAqB,iEAAkE,CAAA;AAEpG;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI1D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two variables a Next.js server (or any server-side code) reads the deployment's address and
|
|
3
|
+
* anon key from: `createServerClient`'s defaults, and the values `@supatype/ssr/next` serves to the
|
|
4
|
+
* page. They are read where the app runs, so one build serves whichever deployment it runs as. A
|
|
5
|
+
* `NEXT_PUBLIC_` name, fixed into the build, is only the server client's fallback.
|
|
6
|
+
*/
|
|
7
|
+
export const SERVER_URL_ENV = "SUPATYPE_URL";
|
|
8
|
+
export const SERVER_ANON_KEY_ENV = "SUPATYPE_ANON_KEY";
|
|
9
|
+
/**
|
|
10
|
+
* Where `createServerClient` looks for each value: the server's own name first, read where the app
|
|
11
|
+
* runs, then the Next.js build-time name an app may already set. The route serves only the first.
|
|
12
|
+
*/
|
|
13
|
+
export const SERVER_URL_NAMES = [SERVER_URL_ENV, "NEXT_PUBLIC_SUPATYPE_URL"];
|
|
14
|
+
export const SERVER_ANON_KEY_NAMES = [SERVER_ANON_KEY_ENV, "NEXT_PUBLIC_SUPATYPE_ANON_KEY"];
|
|
15
|
+
/**
|
|
16
|
+
* A variable from the server's environment, trimmed; undefined when unset or blank, and where there
|
|
17
|
+
* is no `process` at all. Read by name at call time, so no bundler can fix its build-time value in.
|
|
18
|
+
*/
|
|
19
|
+
export function serverEnv(name) {
|
|
20
|
+
if (typeof process === "undefined" || typeof process.env !== "object")
|
|
21
|
+
return undefined;
|
|
22
|
+
const value = process.env[name]?.trim();
|
|
23
|
+
return value === undefined || value === "" ? undefined : value;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=server-env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-env.js","sourceRoot":"","sources":["../src/server-env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAA;AAC5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAA;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,cAAc,EAAE,0BAA0B,CAAU,CAAA;AACrF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,mBAAmB,EAAE,+BAA+B,CAAU,CAAA;AAEpG;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IACvF,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAA;IACvC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;AAChE,CAAC"}
|