@hintergrund/worker 0.1.14 → 0.2.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.
Files changed (46) hide show
  1. package/dist/api/cms/handlers/admin-users.handler.d.ts +0 -1
  2. package/dist/api/cms/handlers/admin-users.handler.d.ts.map +1 -1
  3. package/dist/api/cms/handlers/admin-users.handler.js +2 -27
  4. package/dist/api/cms/handlers/auth.handler.d.ts +0 -4
  5. package/dist/api/cms/handlers/auth.handler.d.ts.map +1 -1
  6. package/dist/api/cms/handlers/auth.handler.js +58 -108
  7. package/dist/api/cms/handlers/github-secrets.handler.d.ts.map +1 -1
  8. package/dist/api/cms/handlers/github-secrets.handler.js +33 -7
  9. package/dist/api/cms/handlers/setup.handler.d.ts +2 -0
  10. package/dist/api/cms/handlers/setup.handler.d.ts.map +1 -1
  11. package/dist/api/cms/handlers/setup.handler.js +87 -30
  12. package/dist/api/cms/handlers/website-repo.handler.d.ts.map +1 -1
  13. package/dist/api/cms/handlers/website-repo.handler.js +11 -4
  14. package/dist/api/cms/handlers/website-templates.handler.d.ts +6 -0
  15. package/dist/api/cms/handlers/website-templates.handler.d.ts.map +1 -0
  16. package/dist/api/cms/handlers/website-templates.handler.js +53 -0
  17. package/dist/api/cms/routes/auth.routes.d.ts.map +1 -1
  18. package/dist/api/cms/routes/auth.routes.js +1 -2
  19. package/dist/api/cms/routes/index.d.ts.map +1 -1
  20. package/dist/api/cms/routes/index.js +7 -3
  21. package/dist/hintergrund-assets.d.ts +4 -4
  22. package/dist/hintergrund-assets.d.ts.map +1 -1
  23. package/dist/hintergrund-assets.js +4 -4
  24. package/dist/index.d.ts +6 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +4 -2
  27. package/dist/lib/email.d.ts +3 -5
  28. package/dist/lib/email.d.ts.map +1 -1
  29. package/dist/lib/email.js +8 -25
  30. package/dist/lib/github-app.d.ts.map +1 -1
  31. package/dist/lib/github-app.js +4 -1
  32. package/dist/lib/github.d.ts +1 -1
  33. package/dist/lib/github.d.ts.map +1 -1
  34. package/dist/lib/github.js +30 -9
  35. package/dist/lib/jsonc.d.ts +3 -0
  36. package/dist/lib/jsonc.d.ts.map +1 -0
  37. package/dist/lib/jsonc.js +76 -0
  38. package/dist/lib/project-db.d.ts +2 -2
  39. package/dist/lib/project-db.d.ts.map +1 -1
  40. package/dist/lib/project-db.js +12 -11
  41. package/dist/middleware/auth.d.ts.map +1 -1
  42. package/dist/middleware/auth.js +0 -1
  43. package/package.json +35 -35
  44. package/dist/api/emails/handlers/webhook.handler.d.ts +0 -9
  45. package/dist/api/emails/handlers/webhook.handler.d.ts.map +0 -1
  46. package/dist/api/emails/handlers/webhook.handler.js +0 -161
@@ -1,7 +1,6 @@
1
1
  import type { Context } from 'hono';
2
2
  import type { HonoEnv } from '../../../index';
3
3
  export declare function listAdminUsers(c: Context<HonoEnv>): Promise<Response>;
4
- export declare function bootstrapAdminUser(c: Context<HonoEnv>): Promise<Response>;
5
4
  export declare function createAdminUser(c: Context<HonoEnv>): Promise<Response>;
6
5
  export declare function patchAdminUser(c: Context<HonoEnv>): Promise<Response>;
7
6
  export declare function deleteAdminUser(c: Context<HonoEnv>): Promise<Response>;
@@ -1 +1 @@
1
- {"version":3,"file":"admin-users.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/admin-users.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAyC9C,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAU3E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAU/E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE5E;AA8BD,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgC3E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiB5E"}
1
+ {"version":3,"file":"admin-users.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/admin-users.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAwB9C,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAU3E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE5E;AA8BD,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgC3E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiB5E"}
@@ -1,6 +1,6 @@
1
1
  import { hashPw } from '../../../lib/auth/crypto';
2
2
  import { createId, ensureSchema, nowSeconds } from '../../../lib/project-db';
3
- const LOGIN_METHODS = ['password', 'magic-link'];
3
+ const LOGIN_METHODS = ['password', 'otp'];
4
4
  function userToResponse(user) {
5
5
  return {
6
6
  id: user.id,
@@ -13,21 +13,6 @@ function userToResponse(user) {
13
13
  hasPassword: !!user.password_hash,
14
14
  };
15
15
  }
16
- async function hasAdminUsers(c) {
17
- const db = await ensureSchema(c.env);
18
- const row = await db.prepare('SELECT COUNT(*) AS count FROM admin_users').first();
19
- return (row?.count ?? 0) > 0;
20
- }
21
- function verifyBootstrapToken(c, provided) {
22
- const configured = c.env.BOOTSTRAP_TOKEN?.trim();
23
- if (!configured) {
24
- return c.json({ error: 'Admin bootstrap is not configured' }, 403);
25
- }
26
- if (String(provided ?? '') !== configured) {
27
- return c.json({ error: 'Invalid bootstrap token' }, 403);
28
- }
29
- return null;
30
- }
31
16
  export async function listAdminUsers(c) {
32
17
  const db = await ensureSchema(c.env);
33
18
  const { results } = await db
@@ -39,23 +24,13 @@ export async function listAdminUsers(c) {
39
24
  }));
40
25
  return c.json({ users });
41
26
  }
42
- export async function bootstrapAdminUser(c) {
43
- const body = await c.req.json();
44
- const tokenError = verifyBootstrapToken(c, body.bootstrapToken ?? c.req.header('x-bootstrap-token'));
45
- if (tokenError)
46
- return tokenError;
47
- if (await hasAdminUsers(c)) {
48
- return c.json({ error: 'Admin users already exist' }, 409);
49
- }
50
- return createAdminUserFromBody(c, body, 201);
51
- }
52
27
  export async function createAdminUser(c) {
53
28
  return createAdminUserFromBody(c, await c.req.json(), 201);
54
29
  }
55
30
  async function createAdminUserFromBody(c, body, status) {
56
31
  const email = String(body.email ?? '').toLowerCase().trim();
57
32
  const name = body.name ? String(body.name).trim() : null;
58
- const loginMethod = LOGIN_METHODS.includes(body.loginMethod) ? body.loginMethod : 'magic-link';
33
+ const loginMethod = LOGIN_METHODS.includes(body.loginMethod) ? body.loginMethod : 'otp';
59
34
  if (!email) {
60
35
  return c.json({ error: 'Email is required' }, 400);
61
36
  }
@@ -1,9 +1,5 @@
1
1
  import { Context } from 'hono';
2
2
  import { HonoEnv } from '../../../index';
3
3
  export declare function login(c: Context<HonoEnv>): Promise<Response>;
4
- /**
5
- * Verify magic link token and log user in
6
- */
7
- export declare function verifyMagicLink(c: Context<HonoEnv>): Promise<Response>;
8
4
  export declare function logout(c: Context<HonoEnv>): Promise<Response>;
9
5
  //# sourceMappingURL=auth.handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/auth.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAiBzC,wBAAsB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsClE;AAiFD;;GAEG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqD5E;AAYD,wBAAsB,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWnE"}
1
+ {"version":3,"file":"auth.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/auth.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAgBzC,wBAAsB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmBlE;AAiFD,wBAAsB,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAOnE"}
@@ -1,8 +1,7 @@
1
- import { readRequestBody, verifyPw, generateRandomToken } from '../../../lib/auth/crypto';
1
+ import { readRequestBody, verifyPw } from '../../../lib/auth/crypto';
2
2
  import { signWithPayload } from '../../../lib/auth/jwt';
3
3
  import { loadConfig } from '../../../lib/config';
4
- import { sendMagicLinkEmail } from '../../../lib/email';
5
- import { readEmailSettings } from '../../emails/handlers/settings.handler';
4
+ import { sendEmailOtp } from '../../../lib/email';
6
5
  import { createId, ensureSchema, getAdminUserByEmail, issueSessionForUser, nowSeconds, sha256Base64Url } from '../../../lib/project-db';
7
6
  export async function login(c) {
8
7
  try {
@@ -10,128 +9,82 @@ export async function login(c) {
10
9
  const body = await readRequestBody(c.req.raw);
11
10
  const isSecure = c.req.url.startsWith('https://');
12
11
  const email = body.email?.toLowerCase().trim();
13
- if (!email) {
14
- return new Response(JSON.stringify({ success: false, message: 'Email is required' }), { status: 400 });
15
- }
12
+ if (!email)
13
+ return loginError('Email is required', 400);
16
14
  const user = await getAdminUserByEmail(c.env, email);
17
- if (!user) {
18
- return new Response(JSON.stringify({ success: false, message: 'Invalid credentials' }), { status: 401 });
19
- }
20
- if (body.password) {
15
+ if (!user)
16
+ return loginError('Invalid credentials', 401);
17
+ if (body.password)
21
18
  return await handleProjectPasswordLogin(c, body.password, appConfig.global.hgSecret, user, isSecure);
22
- }
23
19
  if (user.login_method === 'password') {
24
- return new Response(JSON.stringify({ success: true, requirePassword: true }), { status: 200 });
20
+ return c.json({ success: true, requirePassword: true });
25
21
  }
26
- return await handleProjectMagicLinkLogin(c, user, appConfig);
22
+ return await handleProjectEmailOtpLogin(c, body.otp, user, appConfig, isSecure);
27
23
  }
28
24
  catch (error) {
29
25
  console.error('Login error:', error);
30
- return new Response(JSON.stringify({ success: false, message: String(error) }), { status: 401 });
26
+ return loginError('Unable to sign in. Try again.', 401);
31
27
  }
32
28
  }
29
+ function loginError(message, status) {
30
+ return new Response(JSON.stringify({ success: false, message }), { status });
31
+ }
33
32
  async function handleProjectPasswordLogin(c, password, hgSecret, user, isSecure) {
34
- if (user.login_method !== 'password' || !user.password_hash) {
35
- return new Response(JSON.stringify({ success: false, message: 'Password login is not enabled for this user' }), { status: 400 });
36
- }
37
- if (!(await verifyPw(user.password_hash, password, hgSecret))) {
38
- return new Response(JSON.stringify({ success: false, message: 'Invalid credentials' }), { status: 401 });
39
- }
40
- const token = await signWithPayload(hgSecret, issueSessionForUser(user));
41
- const secureCookie = isSecure ? '; Secure' : '';
42
- return new Response(JSON.stringify({ success: true }), {
43
- status: 200,
44
- headers: {
45
- 'Set-Cookie': `token=${token}; HttpOnly; Path=/; SameSite=Strict${secureCookie}`
46
- }
47
- });
33
+ if (user.login_method !== 'password' || !user.password_hash)
34
+ return loginError('Password sign-in is not enabled for this user', 400);
35
+ if (!(await verifyPw(user.password_hash, password, hgSecret)))
36
+ return loginError('Invalid credentials', 401);
37
+ return signedInResponse(hgSecret, user, isSecure);
48
38
  }
49
- async function handleProjectMagicLinkLogin(c, user, appConfig) {
50
- if (user.login_method !== 'magic-link') {
51
- return new Response(JSON.stringify({ success: false, message: 'Magic link login is not enabled for this user' }), { status: 400 });
52
- }
39
+ async function handleProjectEmailOtpLogin(c, otp, user, appConfig, isSecure) {
40
+ if (user.login_method !== 'otp')
41
+ return loginError('Email-code sign-in is not enabled for this user', 400);
53
42
  const emailsConfig = appConfig.emails;
54
- if (!emailsConfig?.emailApiKey) {
55
- return new Response(JSON.stringify({ success: false, message: 'Emails module is not configured' }), { status: 500 });
56
- }
57
- const token = generateRandomToken();
58
- const tokenHash = await sha256Base64Url(`${token}.${appConfig.global.hgSecret}`);
43
+ if (!emailsConfig?.emailApiKey)
44
+ return loginError('Emails module is not configured', 500);
59
45
  const db = await ensureSchema(c.env);
60
46
  const now = nowSeconds();
61
- await db
62
- .prepare(`INSERT INTO admin_magic_links (id, user_id, token_hash, expires_at, used_at, created_at)
63
- VALUES (?, ?, ?, ?, NULL, ?)`)
64
- .bind(createId('magic'), user.id, tokenHash, now + 15 * 60, now)
65
- .run();
66
- const baseUrl = c.req.url.replace(/\/api\/admin\/login.*$/, '');
67
- const magicLinkUrl = `${baseUrl}/api/admin/verify-magic-link?token=${encodeURIComponent(token)}`;
68
- const { settings } = await readEmailSettings(c.env);
69
- await sendMagicLinkEmail({
47
+ const submittedOtp = otp?.trim();
48
+ if (submittedOtp) {
49
+ if (!/^\d{6}$/.test(submittedOtp))
50
+ return loginError('Enter the six-digit code from your email.', 400);
51
+ const codeHash = await otpHash(user.id, submittedOtp, appConfig.global.hgSecret);
52
+ const result = await db.prepare(`UPDATE admin_email_otps
53
+ SET used_at = ?
54
+ WHERE user_id = ? AND code_hash = ? AND used_at IS NULL AND expires_at > ?`).bind(now, user.id, codeHash, now).run();
55
+ if (!result.meta.changes)
56
+ return loginError('That code is invalid or has expired. Request a new one.', 401);
57
+ return signedInResponse(appConfig.global.hgSecret, user, isSecure);
58
+ }
59
+ const code = emailOtp();
60
+ const codeHash = await otpHash(user.id, code, appConfig.global.hgSecret);
61
+ await db.batch([
62
+ db.prepare('DELETE FROM admin_email_otps WHERE user_id = ?').bind(user.id),
63
+ db.prepare(`INSERT INTO admin_email_otps (id, user_id, code_hash, expires_at, used_at, created_at)
64
+ VALUES (?, ?, ?, ?, NULL, ?)`).bind(createId('otp'), user.id, codeHash, now + 15 * 60, now),
65
+ ]);
66
+ const { settings } = await import('../../emails/handlers/settings.handler').then(({ readEmailSettings }) => readEmailSettings(c.env));
67
+ await sendEmailOtp({
70
68
  to: user.email,
71
69
  apiKey: emailsConfig.emailApiKey,
72
70
  fromEmail: settings.fromEmail ?? '',
73
71
  fromName: settings.fromName,
74
- magicLinkUrl,
72
+ code,
75
73
  });
76
- return new Response(JSON.stringify({ success: true, emailSent: true, message: 'Check your email for the login link.' }), { status: 200 });
74
+ return c.json({ success: true, otpRequired: true, message: 'Check your email for a six-digit sign-in code.' });
77
75
  }
78
- /**
79
- * Verify magic link token and log user in
80
- */
81
- export async function verifyMagicLink(c) {
82
- try {
83
- const appConfig = loadConfig(c.env);
84
- const token = c.req.query('token');
85
- const isSecure = c.req.url.startsWith('https://');
86
- const secureCookie = isSecure ? '; Secure' : '';
87
- if (!token) {
88
- return new Response('Missing token', { status: 400 });
89
- }
90
- const db = await ensureSchema(c.env);
91
- const tokenHash = await sha256Base64Url(`${token}.${appConfig.global.hgSecret}`);
92
- const now = nowSeconds();
93
- const link = await db
94
- .prepare(`SELECT * FROM admin_magic_links
95
- WHERE token_hash = ? AND used_at IS NULL AND expires_at > ?
96
- LIMIT 1`)
97
- .bind(tokenHash, now)
98
- .first();
99
- if (!link) {
100
- return redirectToLoginWithError(c, 'Invalid or expired link');
101
- }
102
- const user = await db
103
- .prepare('SELECT * FROM admin_users WHERE id = ? AND disabled_at IS NULL LIMIT 1')
104
- .bind(link.user_id)
105
- .first();
106
- if (!user) {
107
- return redirectToLoginWithError(c, 'Invalid or expired link');
108
- }
109
- await db
110
- .prepare('UPDATE admin_magic_links SET used_at = ? WHERE id = ? AND used_at IS NULL')
111
- .bind(now, link.id)
112
- .run();
113
- const sessionToken = await signWithPayload(appConfig.global.hgSecret, issueSessionForUser(user));
114
- const baseUrl = c.req.url.replace(/\/api\/admin\/verify-magic-link.*$/, '');
115
- return new Response(null, {
116
- status: 302,
117
- headers: {
118
- 'Location': `${baseUrl}/admin`,
119
- 'Set-Cookie': `token=${sessionToken}; HttpOnly; Path=/; SameSite=Strict${secureCookie}`
120
- }
121
- });
122
- }
123
- catch (error) {
124
- console.error('Magic link verification error:', error);
125
- return redirectToLoginWithError(c, 'Invalid or expired link');
126
- }
76
+ function emailOtp() {
77
+ return crypto.getRandomValues(new Uint32Array(1))[0].toString().slice(-6).padStart(6, '0');
127
78
  }
128
- function redirectToLoginWithError(c, message) {
129
- const baseUrl = c.req.url.replace(/\/api\/admin\/verify-magic-link.*$/, '');
130
- return new Response(null, {
131
- status: 302,
132
- headers: {
133
- 'Location': `${baseUrl}/login?error=${encodeURIComponent(message)}`
134
- }
79
+ async function otpHash(userId, code, secret) {
80
+ return sha256Base64Url(`${userId}.${code}.${secret}`);
81
+ }
82
+ async function signedInResponse(secret, user, isSecure) {
83
+ const token = await signWithPayload(secret, issueSessionForUser(user));
84
+ const secureCookie = isSecure ? '; Secure' : '';
85
+ return new Response(JSON.stringify({ success: true }), {
86
+ status: 200,
87
+ headers: { 'Set-Cookie': `token=${token}; HttpOnly; Path=/; SameSite=Strict${secureCookie}` }
135
88
  });
136
89
  }
137
90
  export async function logout(c) {
@@ -139,9 +92,6 @@ export async function logout(c) {
139
92
  const secureCookie = isSecure ? '; Secure' : '';
140
93
  return new Response(null, {
141
94
  status: 303,
142
- headers: {
143
- Location: `/`,
144
- 'Set-Cookie': `token=; HttpOnly; Path=/; Max-Age=0${secureCookie}`
145
- }
95
+ headers: { Location: '/', 'Set-Cookie': `token=; HttpOnly; Path=/; Max-Age=0${secureCookie}` }
146
96
  });
147
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"github-secrets.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/github-secrets.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAqB9C,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAI9E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAe/E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAS/E;AAED,YAAY,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"github-secrets.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/github-secrets.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAwC9C,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAI9E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkB/E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAe/E;AAED,YAAY,EAAE,YAAY,EAAE,CAAC"}
@@ -2,11 +2,29 @@ import { getGitHubConfig } from '../../../lib/config';
2
2
  import { createGitHubClient } from '../../../lib/github';
3
3
  const SECRET_NAME = /^[A-Z_][A-Z0-9_]*$/;
4
4
  const MAX_SECRET_BYTES = 64 * 1024;
5
+ // These are the only Actions secrets consumed by the generated deployment
6
+ // workflow. Arbitrary repository secrets must not be presented as Worker
7
+ // configuration because they would never reach the deployed Worker.
8
+ const DEPLOYABLE_ACTION_SECRET_NAMES = new Set([
9
+ 'SECRET',
10
+ 'APP_PRIVATE_KEY',
11
+ 'STRIPE_SECRET_KEY',
12
+ 'STRIPE_WEBHOOK_SECRET',
13
+ 'API_KEY',
14
+ 'SETUP_TOKEN',
15
+ ]);
16
+ const DELETABLE_ACTION_SECRET_NAMES = new Set([
17
+ 'STRIPE_SECRET_KEY',
18
+ 'STRIPE_WEBHOOK_SECRET',
19
+ 'API_KEY',
20
+ ]);
5
21
  function secretName(value) {
6
22
  const name = value.trim();
7
23
  return SECRET_NAME.test(name) ? name : null;
8
24
  }
9
25
  async function dispatchDeploy(c) {
26
+ if (c.env.DISABLE_DEPLOYMENTS === 'true')
27
+ return false;
10
28
  const client = createGitHubClient(getGitHubConfig(c.env));
11
29
  const { owner, repo, branch } = client.getRepoInfo();
12
30
  await (await client.getOctokit()).rest.actions.createWorkflowDispatch({
@@ -15,16 +33,20 @@ async function dispatchDeploy(c) {
15
33
  workflow_id: 'deploy.yml',
16
34
  ref: branch,
17
35
  });
36
+ return true;
18
37
  }
19
38
  export async function listGitHubSecrets(c) {
20
39
  const client = createGitHubClient(getGitHubConfig(c.env));
21
- const secrets = await client.listActionsSecrets();
40
+ const secrets = (await client.listActionsSecrets()).filter((secret) => DEPLOYABLE_ACTION_SECRET_NAMES.has(secret.name));
22
41
  return c.json({ secrets });
23
42
  }
24
43
  export async function upsertGitHubSecret(c) {
25
44
  const name = secretName(c.req.param('name') ?? '');
26
45
  if (!name)
27
46
  return c.json({ error: 'Secret names must use uppercase letters, numbers, and underscores.' }, 400);
47
+ if (!DEPLOYABLE_ACTION_SECRET_NAMES.has(name)) {
48
+ return c.json({ error: `Unsupported deployment secret: ${name}` }, 400);
49
+ }
28
50
  const body = await c.req.json();
29
51
  if (typeof body.value !== 'string')
30
52
  return c.json({ error: 'Secret value is required.' }, 400);
@@ -34,18 +56,22 @@ export async function upsertGitHubSecret(c) {
34
56
  const client = createGitHubClient(getGitHubConfig(c.env));
35
57
  await client.setActionsSecret(name, body.value);
36
58
  const deploy = body.deploy !== false;
37
- if (deploy)
38
- await dispatchDeploy(c);
39
- return c.json({ success: true, deployed: deploy });
59
+ const deploymentStarted = deploy ? await dispatchDeploy(c) : false;
60
+ return c.json({ success: true, deploymentStarted });
40
61
  }
41
62
  export async function deleteGitHubSecret(c) {
42
63
  const name = secretName(c.req.param('name') ?? '');
43
64
  if (!name)
44
65
  return c.json({ error: 'Secret names must use uppercase letters, numbers, and underscores.' }, 400);
66
+ if (!DEPLOYABLE_ACTION_SECRET_NAMES.has(name)) {
67
+ return c.json({ error: `Unsupported deployment secret: ${name}` }, 400);
68
+ }
69
+ if (!DELETABLE_ACTION_SECRET_NAMES.has(name)) {
70
+ return c.json({ error: `${name} is required project infrastructure and cannot be deleted.` }, 400);
71
+ }
45
72
  const client = createGitHubClient(getGitHubConfig(c.env));
46
73
  await client.deleteActionsSecret(name);
47
74
  const deploy = c.req.query('deploy') !== 'false';
48
- if (deploy)
49
- await dispatchDeploy(c);
50
- return c.json({ success: true, deployed: deploy });
75
+ const deploymentStarted = deploy ? await dispatchDeploy(c) : false;
76
+ return c.json({ success: true, deploymentStarted });
51
77
  }
@@ -1,6 +1,8 @@
1
1
  import type { Context } from 'hono';
2
2
  import type { HonoEnv } from '../../../index';
3
+ export declare function hasValidSetupToken(env: HonoEnv['Bindings'], provided: unknown): Promise<boolean>;
3
4
  /** One-time, project-owned bootstrap. It is unavailable as soon as an admin exists. */
5
+ export declare function setupContext(c: Context<HonoEnv>): Promise<Response>;
4
6
  export declare function setupProject(c: Context<HonoEnv>): Promise<Response>;
5
7
  export declare function projectNeedsSetup(c: Context<HonoEnv>): Promise<boolean>;
6
8
  //# sourceMappingURL=setup.handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/setup.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AASpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA8B9C,uFAAuF;AACvF,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiFzE;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E"}
1
+ {"version":3,"file":"setup.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/setup.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AASpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAuB9C,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAQtG;AAQD,uFAAuF;AACvF,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAIzE;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmHzE;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E"}
@@ -7,7 +7,6 @@ import { DEFAULT_EMAIL_SETTINGS, EMAIL_SETTINGS_PATH } from '../../emails/handle
7
7
  import Stripe from 'stripe';
8
8
  import { createId, ensureSchema, issueSessionForUser, nowSeconds } from '../../../lib/project-db';
9
9
  const SHOP_SETTINGS_PATH = 'frontend/src/lib/shop/settings.json';
10
- const GLOBALS_PATH = 'frontend/src/lib/content/globals.json';
11
10
  const DEFAULT_SHOP_SETTINGS = {
12
11
  currency: 'eur',
13
12
  enabledPaymentMethods: ['bank_transfer'],
@@ -17,43 +16,101 @@ const DEFAULT_SHOP_SETTINGS = {
17
16
  orderNumberPrefix: 'ORD',
18
17
  invoiceNumberPrefix: 'INV',
19
18
  };
20
- function slugify(value) {
21
- return value.toLowerCase().normalize('NFKD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'site';
22
- }
23
19
  async function hasAdminUsers(c) {
24
20
  const db = await ensureSchema(c.env);
25
21
  const row = await db.prepare('SELECT COUNT(*) AS count FROM admin_users').first();
26
22
  return (row?.count ?? 0) > 0;
27
23
  }
28
- async function deploy(c) {
29
- const client = createGitHubClient(getGitHubConfig(c.env));
24
+ async function tokenHash(value) {
25
+ return new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value)));
26
+ }
27
+ export async function hasValidSetupToken(env, provided) {
28
+ const expected = env.SETUP_TOKEN?.trim();
29
+ const received = typeof provided === 'string' ? provided.trim() : '';
30
+ if (!expected || !received)
31
+ return false;
32
+ const [expectedHash, receivedHash] = await Promise.all([tokenHash(expected), tokenHash(received)]);
33
+ let difference = 0;
34
+ for (let index = 0; index < expectedHash.length; index += 1)
35
+ difference |= expectedHash[index] ^ receivedHash[index];
36
+ return difference === 0;
37
+ }
38
+ async function deploy(c, client = createGitHubClient(getGitHubConfig(c.env))) {
39
+ if (c.env.DISABLE_DEPLOYMENTS === 'true')
40
+ return;
30
41
  const { owner, repo, branch } = client.getRepoInfo();
31
42
  await (await client.getOctokit()).rest.actions.createWorkflowDispatch({ owner, repo, workflow_id: 'deploy.yml', ref: branch });
32
43
  }
33
44
  /** One-time, project-owned bootstrap. It is unavailable as soon as an admin exists. */
45
+ export async function setupContext(c) {
46
+ if (await hasAdminUsers(c))
47
+ return c.json({ error: 'Project setup has already been completed.' }, 409);
48
+ if (!(await hasValidSetupToken(c.env, c.req.query('token'))))
49
+ return c.json({ error: 'Invalid setup link.' }, 403);
50
+ return c.json({ suggestedEmail: c.env.SETUP_ADMIN_EMAIL?.trim() || undefined });
51
+ }
34
52
  export async function setupProject(c) {
35
53
  if (await hasAdminUsers(c))
36
54
  return c.json({ error: 'Project setup has already been completed.' }, 409);
37
55
  const body = await c.req.json();
56
+ if (!(await hasValidSetupToken(c.env, body.setupToken)))
57
+ return c.json({ error: 'Invalid setup link.' }, 403);
38
58
  const email = typeof body.email === 'string' ? body.email.trim().toLowerCase() : '';
59
+ const loginMethod = body.loginMethod === 'otp' || body.loginMethod === 'password' ? body.loginMethod : null;
39
60
  const password = typeof body.password === 'string' ? body.password : '';
40
- const name = typeof body.username === 'string' ? body.username.trim() : null;
41
- const siteTitle = typeof body.siteTitle === 'string' ? body.siteTitle.trim() : '';
42
- if (!email || !password || !siteTitle)
43
- return c.json({ error: 'Site title, email, and password are required.' }, 400);
44
- if (password.length < 12)
45
- return c.json({ error: 'Use a password of at least 12 characters.' }, 400);
61
+ const plunkApiKey = typeof body.plunkApiKey === 'string' ? body.plunkApiKey.trim() : '';
62
+ const fromEmail = typeof body.fromEmail === 'string' ? body.fromEmail.trim() : '';
63
+ const paymentProvider = body.paymentProvider === 'stripe' || body.paymentProvider === 'bank_transfer' ? body.paymentProvider : null;
64
+ if (!email || !loginMethod)
65
+ return c.json({ error: 'An email address and sign-in method are required.' }, 400);
66
+ if (loginMethod === 'password' && !password)
67
+ return c.json({ error: 'A password is required when password sign-in is selected.' }, 400);
68
+ if (loginMethod === 'otp' && (!plunkApiKey || !fromEmail)) {
69
+ return c.json({ error: 'Configure Plunk and a sender email to use email codes.' }, 400);
70
+ }
71
+ if (!paymentProvider)
72
+ return c.json({ error: 'Choose a payment provider.' }, 400);
73
+ const bankTransfer = typeof body.bankTransfer === 'object' && body.bankTransfer !== null ? body.bankTransfer : {};
74
+ const accountHolder = typeof bankTransfer.accountHolder === 'string' ? bankTransfer.accountHolder.trim() : '';
75
+ const iban = typeof bankTransfer.iban === 'string' ? bankTransfer.iban.trim() : '';
76
+ const stripeSecretKey = paymentProvider === 'stripe' && typeof body.stripeSecretKey === 'string' ? body.stripeSecretKey.trim() : '';
77
+ if (paymentProvider === 'bank_transfer' && (!accountHolder || !iban)) {
78
+ return c.json({ error: 'An account holder and IBAN are required for bank transfers.' }, 400);
79
+ }
80
+ if (paymentProvider === 'stripe' && !stripeSecretKey)
81
+ return c.json({ error: 'Your Stripe secret key is required for card payments.' }, 400);
82
+ // Do not consume the one-time setup route until GitHub is reachable. A project
83
+ // without its repository cannot complete setup and must remain retryable.
84
+ let client;
85
+ try {
86
+ client = createGitHubClient(getGitHubConfig(c.env));
87
+ await client.getCommitSha();
88
+ }
89
+ catch (error) {
90
+ console.error('Project setup GitHub preflight failed:', error);
91
+ return c.json({ error: 'GitHub repository is unavailable. Check the project GitHub App configuration and try again.' }, 503);
92
+ }
46
93
  const db = await ensureSchema(c.env);
47
94
  const now = nowSeconds();
48
95
  const user = {
49
- id: createId('user'), email, name, login_method: 'password', password_hash: await hashPw(password, c.env.SECRET ?? ''),
50
- disabled_at: null, created_at: now, updated_at: now,
96
+ id: createId('user'),
97
+ email,
98
+ name: null,
99
+ login_method: loginMethod,
100
+ password_hash: loginMethod === 'password' ? await hashPw(password, c.env.SECRET ?? '') : null,
101
+ disabled_at: null,
102
+ created_at: now,
103
+ updated_at: now,
51
104
  };
52
- await db.prepare(`INSERT INTO admin_users (id, email, name, password_hash, login_method, disabled_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?, NULL, ?, ?)`)
53
- .bind(user.id, user.email, user.name, user.password_hash, user.login_method, now, now).run();
54
105
  try {
55
- const client = createGitHubClient(getGitHubConfig(c.env));
56
- const stripeSecretKey = body.paymentProvider === 'stripe' && typeof body.stripeSecretKey === 'string' ? body.stripeSecretKey.trim() : '';
106
+ await db.prepare(`INSERT INTO admin_users (id, email, password_hash, login_method, initial_admin, disabled_at, created_at, updated_at) VALUES (?, ?, ?, ?, 1, NULL, ?, ?)`)
107
+ .bind(user.id, user.email, user.password_hash, user.login_method, now, now).run();
108
+ }
109
+ catch (error) {
110
+ console.error('Initial admin creation failed', error);
111
+ return c.json({ error: 'Project setup has already been completed.' }, 409);
112
+ }
113
+ try {
57
114
  let stripeWebhookSecret = typeof body.stripeWebhookSecret === 'string' ? body.stripeWebhookSecret : '';
58
115
  if (stripeSecretKey && !stripeWebhookSecret) {
59
116
  try {
@@ -69,7 +126,7 @@ export async function setupProject(c) {
69
126
  }
70
127
  const secrets = {};
71
128
  for (const [name, value] of [
72
- ['API_KEY', body.plunkApiKey],
129
+ ['API_KEY', plunkApiKey],
73
130
  ['STRIPE_SECRET_KEY', stripeSecretKey],
74
131
  ['STRIPE_WEBHOOK_SECRET', stripeWebhookSecret],
75
132
  ]) {
@@ -77,23 +134,16 @@ export async function setupProject(c) {
77
134
  secrets[name] = value;
78
135
  }
79
136
  await Promise.all(Object.entries(secrets).map(([secretName, value]) => client.setActionsSecret(secretName, value)));
80
- const { data: globals, commitSha: globalsCommitSha } = await readJsonConfig(client, GLOBALS_PATH, { siteName: '', siteSlug: '' });
81
- await writeJsonConfig(client, GLOBALS_PATH, {
82
- ...globals,
83
- siteName: siteTitle,
84
- siteSlug: slugify(siteTitle),
85
- }, 'Set initial site title [skip ci]', globalsCommitSha);
86
137
  const { data: shopSettings, commitSha: shopCommitSha } = await readJsonConfig(client, SHOP_SETTINGS_PATH, DEFAULT_SHOP_SETTINGS);
87
- const bankTransfer = typeof body.bankTransfer === 'object' && body.bankTransfer !== null ? body.bankTransfer : {};
88
138
  await writeJsonConfig(client, SHOP_SETTINGS_PATH, {
89
139
  ...DEFAULT_SHOP_SETTINGS,
90
140
  ...shopSettings,
91
- enabledPaymentMethods: stripeSecretKey ? ['bank_transfer', 'stripe'] : ['bank_transfer'],
141
+ enabledPaymentMethods: paymentProvider === 'stripe' ? ['stripe'] : ['bank_transfer'],
92
142
  bankTransfer: {
93
143
  ...DEFAULT_SHOP_SETTINGS.bankTransfer,
94
144
  ...(shopSettings.bankTransfer ?? {}),
95
- accountHolder: typeof bankTransfer.accountHolder === 'string' ? bankTransfer.accountHolder.trim() : '',
96
- iban: typeof bankTransfer.iban === 'string' ? bankTransfer.iban.trim() : '',
145
+ accountHolder,
146
+ iban,
97
147
  bic: typeof bankTransfer.bic === 'string' ? bankTransfer.bic.trim() : '',
98
148
  bankName: typeof bankTransfer.bankName === 'string' ? bankTransfer.bankName.trim() : '',
99
149
  instructions: typeof bankTransfer.instructions === 'string' ? bankTransfer.instructions.trim() : DEFAULT_SHOP_SETTINGS.bankTransfer.instructions,
@@ -107,10 +157,17 @@ export async function setupProject(c) {
107
157
  replyTo: typeof body.replyTo === 'string' ? body.replyTo.trim() : emailSettings.replyTo,
108
158
  updatedAt: Date.now(),
109
159
  }, 'Configure email sender settings [skip ci]', commitSha);
110
- await deploy(c);
160
+ await deploy(c, client);
111
161
  }
112
162
  catch (error) {
113
163
  console.error('Project setup integrations could not be saved:', error);
164
+ try {
165
+ await db.prepare('DELETE FROM admin_users WHERE id = ?').bind(user.id).run();
166
+ }
167
+ catch (rollbackError) {
168
+ console.error('Could not roll back incomplete project setup:', rollbackError);
169
+ }
170
+ return c.json({ error: 'Project setup could not be completed. No administrator was created; fix the integration error and try again.' }, 502);
114
171
  }
115
172
  const token = await signWithPayload(c.env.SECRET ?? '', issueSessionForUser({ ...user, password_hash: user.password_hash }));
116
173
  const secureCookie = c.req.url.startsWith('https://') ? '; Secure' : '';
@@ -1 +1 @@
1
- {"version":3,"file":"website-repo.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/website-repo.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAyB9C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI1D;AA4CD,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAI5E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAc5E;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgC9E;AASD,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6C/E"}
1
+ {"version":3,"file":"website-repo.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/website-repo.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAyB9C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI1D;AA4CD,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAI5E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAc5E;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAwC9E;AASD,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6C/E"}
@@ -84,11 +84,18 @@ export async function commitWebsiteRepo(c) {
84
84
  content: String(file.content ?? ''),
85
85
  encoding: file.encoding === 'base64' ? 'base64' : 'utf8',
86
86
  }));
87
- const invalidPath = files.find((f) => !isAllowedWebsitePath(f.path));
87
+ const deletions = Array.isArray(body.deletions)
88
+ ? [...new Set(body.deletions.map((path) => normalizePath(String(path ?? ''))))]
89
+ : [];
90
+ const invalidPath = [...files.map((file) => file.path), ...deletions].find((path) => !isAllowedWebsitePath(path));
88
91
  if (invalidPath) {
89
- return c.json({ error: `Path is not allowed for website sync: ${invalidPath.path}` }, 400);
92
+ return c.json({ error: `Path is not allowed for website sync: ${invalidPath}` }, 400);
90
93
  }
91
- if (files.length === 0) {
94
+ const writtenPaths = new Set(files.map((file) => file.path));
95
+ if (deletions.some((path) => writtenPaths.has(path))) {
96
+ return c.json({ error: 'A path cannot be written and deleted in the same commit' }, 400);
97
+ }
98
+ if (files.length === 0 && deletions.length === 0) {
92
99
  return c.json({ error: 'No files to commit' }, 400);
93
100
  }
94
101
  const client = createGitHubClient(getGitHubConfig(c.env));
@@ -98,7 +105,7 @@ export async function commitWebsiteRepo(c) {
98
105
  return c.json({ conflict: true, message: 'Repository changed since the last sync' }, 409);
99
106
  }
100
107
  }
101
- const commitSha = await client.writeFilesAtomic(files, String(body.message || 'Publish website changes'), body.baseCommitSha ? String(body.baseCommitSha) : undefined);
108
+ const commitSha = await client.writeFilesAtomic(files, String(body.message || 'Publish website changes'), body.baseCommitSha ? String(body.baseCommitSha) : undefined, deletions);
102
109
  return c.json({ success: true, commitSha });
103
110
  }
104
111
  function sanitizeFilename(name) {
@@ -0,0 +1,6 @@
1
+ import type { Context } from 'hono';
2
+ import type { HonoEnv } from '../../../index';
3
+ export declare function listWebsiteTemplates(c: Context<HonoEnv>): Promise<Response>;
4
+ export declare function getWebsiteTemplateManifest(c: Context<HonoEnv>): Promise<Response>;
5
+ export declare function getWebsiteTemplateFile(c: Context<HonoEnv>): Promise<Response>;
6
+ //# sourceMappingURL=website-templates.handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"website-templates.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/website-templates.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA0C9C,wBAAsB,oBAAoB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEjF;AAED,wBAAsB,0BAA0B,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAKvF;AAED,wBAAsB,sBAAsB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAQnF"}