@codelitdev/platform-cli 0.9.0 → 0.11.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/preset.json
CHANGED
|
@@ -5,42 +5,42 @@
|
|
|
5
5
|
},
|
|
6
6
|
"packages": {
|
|
7
7
|
"@codelitdev/platform": {
|
|
8
|
-
"recommended": "0.
|
|
8
|
+
"recommended": "0.11.0",
|
|
9
9
|
"supported": ">=0.1.0-alpha.0 <2",
|
|
10
10
|
"minimumSecure": "0.1.0-alpha.0"
|
|
11
11
|
},
|
|
12
12
|
"@codelitdev/observability": {
|
|
13
|
-
"recommended": "0.
|
|
13
|
+
"recommended": "0.11.0",
|
|
14
14
|
"supported": ">=0.1.0-alpha.0 <2",
|
|
15
15
|
"minimumSecure": "0.1.0-alpha.0"
|
|
16
16
|
},
|
|
17
17
|
"@codelitdev/mcp-server-kit": {
|
|
18
|
-
"recommended": "0.
|
|
18
|
+
"recommended": "0.11.0",
|
|
19
19
|
"supported": ">=0.1.0-alpha.0 <2",
|
|
20
20
|
"minimumSecure": "0.1.0-alpha.0"
|
|
21
21
|
},
|
|
22
22
|
"@codelitdev/platform-conformance": {
|
|
23
|
-
"recommended": "0.
|
|
23
|
+
"recommended": "0.11.0",
|
|
24
24
|
"supported": ">=0.1.0-alpha.0 <2",
|
|
25
25
|
"minimumSecure": "0.1.0-alpha.0"
|
|
26
26
|
},
|
|
27
27
|
"@codelitdev/platform-cli": {
|
|
28
|
-
"recommended": "0.
|
|
28
|
+
"recommended": "0.11.0",
|
|
29
29
|
"supported": ">=0.1.0-alpha.0 <2",
|
|
30
30
|
"minimumSecure": "0.1.0-alpha.0"
|
|
31
31
|
},
|
|
32
32
|
"@codelitdev/billing": {
|
|
33
|
-
"recommended": "0.
|
|
33
|
+
"recommended": "0.11.0",
|
|
34
34
|
"supported": ">=0.1.0-alpha.4 <1",
|
|
35
35
|
"minimumSecure": "0.1.0-alpha.4"
|
|
36
36
|
},
|
|
37
37
|
"@codelitdev/oauth-server-kit": {
|
|
38
|
-
"recommended": "0.
|
|
38
|
+
"recommended": "0.11.0",
|
|
39
39
|
"supported": ">=0.1.0-alpha.2 <1",
|
|
40
40
|
"minimumSecure": "0.1.0-alpha.2"
|
|
41
41
|
},
|
|
42
42
|
"@codelitdev/design-system": {
|
|
43
|
-
"recommended": "0.
|
|
43
|
+
"recommended": "0.11.0",
|
|
44
44
|
"supported": ">=0.1.0-alpha.7 <1",
|
|
45
45
|
"minimumSecure": "0.1.0-alpha.7"
|
|
46
46
|
}
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"pg": "8.23.0",
|
|
55
55
|
"@types/pg": "8.23.1",
|
|
56
56
|
"zod": "3.25.76",
|
|
57
|
-
"better-auth": "1.7.
|
|
58
|
-
"@better-auth/oauth-provider": "1.7.
|
|
57
|
+
"better-auth": "1.7.22",
|
|
58
|
+
"@better-auth/oauth-provider": "1.7.22",
|
|
59
59
|
"drizzle-orm": "0.45.2",
|
|
60
60
|
"drizzle-kit": "0.31.10",
|
|
61
61
|
"pino": "9.6.0",
|
package/package.json
CHANGED
|
@@ -21,22 +21,22 @@
|
|
|
21
21
|
"pretest": "bun run check:auth-schema"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@better-auth/core": "1.7.
|
|
24
|
+
"@better-auth/core": "1.7.22",
|
|
25
25
|
"@codelitdev/billing": "workspace:*",
|
|
26
26
|
"@codelitdev/oauth-server-kit": "workspace:*",
|
|
27
27
|
"@codelitdev/mcp-server-kit": "workspace:*",
|
|
28
28
|
"@codelitdev/platform-conformance": "workspace:*",
|
|
29
29
|
"@codelitdev/observability": "workspace:*",
|
|
30
|
-
"@better-auth/oauth-provider": "1.7.
|
|
31
|
-
"@better-auth/utils": "0.
|
|
32
|
-
"@better-fetch/fetch": "1.3.
|
|
30
|
+
"@better-auth/oauth-provider": "1.7.22",
|
|
31
|
+
"@better-auth/utils": "0.5.1",
|
|
32
|
+
"@better-fetch/fetch": "1.3.3",
|
|
33
33
|
"@ts-rest/express": "3.52.1",
|
|
34
34
|
"@ts-rest/open-api": "3.52.1",
|
|
35
35
|
"@codelitdev/platform": "workspace:*",
|
|
36
36
|
"@__PRODUCT_SLUG__/api-contract": "workspace:*",
|
|
37
37
|
"@types/pg": "8.23.1",
|
|
38
|
-
"better-call": "1.4.
|
|
39
|
-
"better-auth": "1.7.
|
|
38
|
+
"better-call": "1.4.5",
|
|
39
|
+
"better-auth": "1.7.22",
|
|
40
40
|
"drizzle-orm": "0.45.2",
|
|
41
41
|
"express": "4.21.2",
|
|
42
42
|
"pg": "8.23.0",
|
|
@@ -33,7 +33,9 @@ export async function authenticateHttpRequest(
|
|
|
33
33
|
headers: HeaderMap,
|
|
34
34
|
deps: AuthRuntime,
|
|
35
35
|
): Promise<AuthenticationResult<string>> {
|
|
36
|
-
const selected = selectHttpCredential(headers
|
|
36
|
+
const selected = selectHttpCredential(headers, {
|
|
37
|
+
sessionCookieName: deps.auth.sessionCookieName,
|
|
38
|
+
});
|
|
37
39
|
if (selected.kind === "absent") {
|
|
38
40
|
return mapTransportAuthentication({ kind: "absent" }, { transport: "http" });
|
|
39
41
|
}
|
|
@@ -3,7 +3,12 @@ import { betterAuth } from "better-auth";
|
|
|
3
3
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
4
4
|
import * as authSchema from "../db/schema/auth.generated.js";
|
|
5
5
|
import type { AppDb } from "../types.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
AUTH_BASE_PATH,
|
|
8
|
+
authCookieOptions,
|
|
9
|
+
authUrls,
|
|
10
|
+
referenceAuthOptions,
|
|
11
|
+
} from "./options.js";
|
|
7
12
|
|
|
8
13
|
export function createReferenceAuth(input: {
|
|
9
14
|
db: AppDb;
|
|
@@ -32,6 +37,7 @@ export function createReferenceAuth(input: {
|
|
|
32
37
|
oauthResourceClient,
|
|
33
38
|
...urls,
|
|
34
39
|
authBasePath: AUTH_BASE_PATH,
|
|
40
|
+
sessionCookieName: authCookieOptions(input.publicApiUrl).sessionCookieName,
|
|
35
41
|
};
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { oauthProvider } from "@better-auth/oauth-provider";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createOAuthProviderOptions,
|
|
4
|
+
secureCookieOptions,
|
|
5
|
+
secureEmailAndPasswordOptions,
|
|
6
|
+
secureSessionOptions,
|
|
7
|
+
sessionCookieName,
|
|
8
|
+
} from "@codelitdev/oauth-server-kit/better-auth";
|
|
3
9
|
import type { BetterAuthOptions } from "better-auth";
|
|
4
10
|
import { emailOTP } from "better-auth/plugins/email-otp";
|
|
5
11
|
import { jwt } from "better-auth/plugins/jwt";
|
|
6
12
|
|
|
7
13
|
export const AUTH_BASE_PATH = "/api/auth";
|
|
14
|
+
export const AUTH_COOKIE_PREFIX = "__PRODUCT_SLUG__";
|
|
8
15
|
export const AUTH_SECRET_MIN_LENGTH = 32;
|
|
9
16
|
|
|
10
17
|
export const DATA_READ_SCOPE = "data:read";
|
|
@@ -17,6 +24,15 @@ export const MCP_SCOPES_SUPPORTED = [
|
|
|
17
24
|
"offline_access",
|
|
18
25
|
] as const;
|
|
19
26
|
|
|
27
|
+
/** Better Auth's `advanced` cookie options, plus the session cookie name they produce. */
|
|
28
|
+
export function authCookieOptions(publicApiUrl: string) {
|
|
29
|
+
const advanced = secureCookieOptions({
|
|
30
|
+
baseURL: publicApiUrl,
|
|
31
|
+
cookiePrefix: AUTH_COOKIE_PREFIX,
|
|
32
|
+
});
|
|
33
|
+
return { advanced, sessionCookieName: sessionCookieName(advanced) };
|
|
34
|
+
}
|
|
35
|
+
|
|
20
36
|
export type ReferenceAuthUrls = {
|
|
21
37
|
publicApiUrl: string;
|
|
22
38
|
webOrigin: string;
|
|
@@ -77,8 +93,12 @@ export function referenceAuthOptions(input: {
|
|
|
77
93
|
baseURL: urls.publicApiUrl,
|
|
78
94
|
basePath: AUTH_BASE_PATH,
|
|
79
95
|
secret: input.secret,
|
|
96
|
+
// `__Host-` session cookie over https; each product keeps its own prefix.
|
|
97
|
+
advanced: { ...authCookieOptions(urls.publicApiUrl).advanced },
|
|
98
|
+
// No cookie cache: a revoked session stops working immediately.
|
|
99
|
+
session: secureSessionOptions(),
|
|
80
100
|
trustedOrigins: [urls.webOrigin, urls.publicApiUrl],
|
|
81
|
-
emailAndPassword:
|
|
101
|
+
emailAndPassword: secureEmailAndPasswordOptions(),
|
|
82
102
|
...(input.database ? { database: input.database } : {}),
|
|
83
103
|
plugins: [
|
|
84
104
|
jwt(),
|