create-aphex 0.1.1 → 0.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-aphex",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Scaffold a new Aphex CMS project — invoked via `pnpm create aphex`",
5
5
  "publishConfig": {
6
6
  "provenance": true
@@ -18,6 +18,11 @@ tag matching the version you started from to see the exact changes.
18
18
 
19
19
  ## Unreleased
20
20
 
21
+ ## 0.0.4
22
+ - pass authorised origins from .env into better auth to handle csrf
23
+ - preload dayjs for better UX when going into a fresh studio
24
+ - disallow admins from changing themselves to owners and kicking out original owners
25
+
21
26
  ## 0.0.3
22
27
  - **feat(api): move invitation email-wrap into `aphex.config.ts → api`**
23
28
  - Deleted: `src/routes/api/organizations/invitations/+server.ts` —
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aphexcms/base",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -29,11 +29,11 @@
29
29
  "test:date": "tsx scripts/test-date-localapi.ts"
30
30
  },
31
31
  "dependencies": {
32
- "@aphexcms/cms-core": "^5.0.3",
33
- "@aphexcms/nodemailer-adapter": "^7.0.3",
34
- "@aphexcms/postgresql-adapter": "^6.0.3",
35
- "@aphexcms/resend-adapter": "^6.0.3",
36
- "@aphexcms/storage-s3": "^6.0.3",
32
+ "@aphexcms/cms-core": "^5.0.5",
33
+ "@aphexcms/nodemailer-adapter": "^7.0.5",
34
+ "@aphexcms/postgresql-adapter": "^6.0.5",
35
+ "@aphexcms/resend-adapter": "^6.0.5",
36
+ "@aphexcms/storage-s3": "^6.0.5",
37
37
  "@aphexcms/ui": "^0.4.0",
38
38
  "@better-auth/api-key": "^1.5.3",
39
39
  "@better-auth/drizzle-adapter": "^1.5.3",
@@ -16,6 +16,14 @@ import { cacheAdapter } from '../../cache';
16
16
  const authSecret = env.AUTH_SECRET || env.BETTER_AUTH_SECRET;
17
17
  const authUrl = env.AUTH_URL || env.BETTER_AUTH_URL;
18
18
 
19
+ // CSV of origins permitted for cross-origin auth requests. Better Auth uses
20
+ // this for CSRF/origin checks; without it, cookie-auth API mutations are
21
+ // reachable from any site a logged-in admin visits.
22
+ const trustedOrigins = (env.AUTH_TRUSTED_ORIGINS || authUrl || '')
23
+ .split(',')
24
+ .map((o) => o.trim())
25
+ .filter(Boolean);
26
+
19
27
  // This function creates the Better Auth instance, injecting the necessary dependencies.
20
28
  export function createAuthInstance(
21
29
  db: DatabaseAdapter,
@@ -51,6 +59,16 @@ export function createAuthInstance(
51
59
  return betterAuth({
52
60
  baseURL: authUrl,
53
61
  secret: authSecret,
62
+ trustedOrigins,
63
+ session: {
64
+ // Validates the session cookie's signature without a DB hit. Short
65
+ // maxAge keeps revocation lag tight for role/membership changes,
66
+ // which the per-request RBAC chain re-reads on top of this.
67
+ cookieCache: {
68
+ enabled: true,
69
+ maxAge: 60
70
+ }
71
+ },
54
72
  advanced: {
55
73
  backgroundTasks: {
56
74
  handler: (task) => {
@@ -1,7 +1,12 @@
1
+ import { createRequire } from 'node:module';
1
2
  import tailwindcss from '@tailwindcss/vite';
2
3
  import { sveltekit } from '@sveltejs/kit/vite';
3
4
  import { defineConfig } from 'vite';
4
5
 
6
+ const require = createRequire(import.meta.url);
7
+ const dayjsEsm = require.resolve('dayjs/esm/index.js');
8
+ const dayjsEsmPluginDir = dayjsEsm.replace(/\/index\.js$/, '/plugin');
9
+
5
10
  export default defineConfig({
6
11
  plugins: [
7
12
  tailwindcss(),
@@ -70,8 +75,8 @@ export default defineConfig({
70
75
  // to dayjs's proper ESM build so those imports work regardless of which
71
76
  // package they come from.
72
77
  alias: [
73
- { find: /^dayjs$/, replacement: 'dayjs/esm/index.js' },
74
- { find: /^dayjs\/plugin\/([^/]+?)(\.js)?$/, replacement: 'dayjs/esm/plugin/$1/index.js' }
78
+ { find: /^dayjs$/, replacement: dayjsEsm },
79
+ { find: /^dayjs\/plugin\/([^/]+?)(\.js)?$/, replacement: `${dayjsEsmPluginDir}/$1/index.js` }
75
80
  ]
76
81
  },
77
82
  server: {
@@ -102,6 +107,9 @@ export default defineConfig({
102
107
  'tailwind-merge',
103
108
  '@internationalized/date',
104
109
  'bits-ui',
110
+ 'dayjs',
111
+ 'dayjs/plugin/customParseFormat',
112
+ 'dayjs/plugin/utc',
105
113
  '@lucide/svelte',
106
114
  '@lucide/svelte/icons/panel-left',
107
115
  '@lucide/svelte/icons/minus',