@hintergrund/worker 0.1.10 → 0.1.14
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/api/cms/handlers/admin-users.handler.js +9 -9
- package/dist/api/cms/handlers/agent-conversations.handler.js +4 -4
- package/dist/api/cms/handlers/auth.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/auth.handler.js +7 -5
- package/dist/api/cms/handlers/github-secrets.handler.d.ts +8 -0
- package/dist/api/cms/handlers/github-secrets.handler.d.ts.map +1 -0
- package/dist/api/cms/handlers/github-secrets.handler.js +51 -0
- package/dist/api/cms/handlers/setup.handler.d.ts +6 -0
- package/dist/api/cms/handlers/setup.handler.d.ts.map +1 -0
- package/dist/api/cms/handlers/setup.handler.js +121 -0
- package/dist/api/cms/routes/index.d.ts.map +1 -1
- package/dist/api/cms/routes/index.js +6 -0
- package/dist/api/emails/handlers/webhook.handler.js +1 -1
- package/dist/api/shop/handlers/products.handler.js +1 -1
- package/dist/api/shop/handlers/public.handler.js +11 -11
- package/dist/hintergrund-assets.d.ts +1 -1
- package/dist/hintergrund-assets.d.ts.map +1 -1
- package/dist/hintergrund-assets.js +1 -1
- package/dist/index.d.ts +18 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -8
- package/dist/lib/auth/jwt.d.ts +0 -4
- package/dist/lib/auth/jwt.d.ts.map +1 -1
- package/dist/lib/auth/jwt.js +0 -7
- package/dist/lib/config.d.ts +7 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +34 -22
- package/dist/lib/email.d.ts +1 -1
- package/dist/lib/email.d.ts.map +1 -1
- package/dist/lib/email.js +13 -10
- package/dist/lib/github-app.d.ts +1 -0
- package/dist/lib/github-app.d.ts.map +1 -1
- package/dist/lib/github-app.js +22 -1
- package/dist/lib/github.d.ts +18 -2
- package/dist/lib/github.d.ts.map +1 -1
- package/dist/lib/github.js +61 -3
- package/dist/lib/project-db.d.ts +0 -2
- package/dist/lib/project-db.d.ts.map +1 -1
- package/dist/lib/project-db.js +3 -7
- package/dist/lib/template.d.ts.map +1 -1
- package/dist/lib/template.js +79 -208
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +5 -4
- package/package.json +35 -33
package/dist/lib/template.js
CHANGED
|
@@ -4,223 +4,94 @@ export function getTemplate(element, uiBaseUrl, params = '') {
|
|
|
4
4
|
return `
|
|
5
5
|
<!doctype html>
|
|
6
6
|
<html>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<script type="module" src="${uiBaseUrl}/login.js"></script>
|
|
21
|
-
</body>
|
|
22
|
-
</html>
|
|
23
|
-
`;
|
|
7
|
+
<head>
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
<title>Login</title>
|
|
11
|
+
<link rel="icon" type="image/svg+xml" href="${faviconSvg}">
|
|
12
|
+
<style>* { box-sizing: border-box; margin: 0; padding: 0; } body { margin: 0; height: 100vh; }</style>
|
|
13
|
+
<link rel="stylesheet" href="${uiBaseUrl}/ui.css">
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<hintergrund-login ${params}></hintergrund-login>
|
|
17
|
+
<script type="module" src="${uiBaseUrl}/login.js"></script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>`;
|
|
24
20
|
}
|
|
25
|
-
if (element === '
|
|
21
|
+
if (element === 'setup') {
|
|
26
22
|
return `
|
|
27
23
|
<!doctype html>
|
|
28
24
|
<html>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<hintergrund-admin ${params}></hintergrund-admin>
|
|
43
|
-
<script type="module" src="${uiBaseUrl}/admin.js"></script>
|
|
44
|
-
</body>
|
|
45
|
-
</html>
|
|
46
|
-
`;
|
|
25
|
+
<head>
|
|
26
|
+
<meta charset="utf-8">
|
|
27
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
28
|
+
<title>Set up your site</title>
|
|
29
|
+
<link rel="icon" type="image/svg+xml" href="${faviconSvg}">
|
|
30
|
+
<style>body { margin: 0; }</style>
|
|
31
|
+
<link rel="stylesheet" href="${uiBaseUrl}/ui.css">
|
|
32
|
+
</head>
|
|
33
|
+
<body>
|
|
34
|
+
<hintergrund-setup></hintergrund-setup>
|
|
35
|
+
<script type="module" src="${uiBaseUrl}/setup.js"></script>
|
|
36
|
+
</body>
|
|
37
|
+
</html>`;
|
|
47
38
|
}
|
|
48
|
-
if (element === '
|
|
39
|
+
if (element === 'admin') {
|
|
49
40
|
return `
|
|
50
41
|
<!doctype html>
|
|
51
42
|
<html>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
padding: 1rem;
|
|
67
|
-
}
|
|
68
|
-
.container {
|
|
69
|
-
background: white;
|
|
70
|
-
border-radius: 8px;
|
|
71
|
-
border: 1px solid #d0d7de;
|
|
72
|
-
padding: 2rem;
|
|
73
|
-
max-width: 480px;
|
|
74
|
-
width: 100%;
|
|
75
|
-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
|
76
|
-
}
|
|
77
|
-
h1 {
|
|
78
|
-
font-size: 1.5rem;
|
|
79
|
-
font-weight: 600;
|
|
80
|
-
margin-bottom: 1rem;
|
|
81
|
-
color: #24292f;
|
|
82
|
-
}
|
|
83
|
-
p {
|
|
84
|
-
color: #57606a;
|
|
85
|
-
line-height: 1.5;
|
|
86
|
-
margin-bottom: 1.5rem;
|
|
87
|
-
}
|
|
88
|
-
.buttons {
|
|
89
|
-
display: flex;
|
|
90
|
-
gap: 0.75rem;
|
|
91
|
-
}
|
|
92
|
-
button {
|
|
93
|
-
flex: 1;
|
|
94
|
-
padding: 0.75rem 1rem;
|
|
95
|
-
font-size: 0.875rem;
|
|
96
|
-
font-weight: 500;
|
|
97
|
-
border-radius: 6px;
|
|
98
|
-
border: 1px solid;
|
|
99
|
-
cursor: pointer;
|
|
100
|
-
transition: all 0.15s ease;
|
|
101
|
-
}
|
|
102
|
-
.btn-primary {
|
|
103
|
-
background: #cf222e;
|
|
104
|
-
color: white;
|
|
105
|
-
border-color: #cf222e;
|
|
106
|
-
}
|
|
107
|
-
.btn-primary:hover {
|
|
108
|
-
background: #a40e26;
|
|
109
|
-
border-color: #a40e26;
|
|
110
|
-
}
|
|
111
|
-
.btn-secondary {
|
|
112
|
-
background: #f6f8fa;
|
|
113
|
-
color: #24292f;
|
|
114
|
-
border-color: #d0d7de;
|
|
115
|
-
}
|
|
116
|
-
.btn-secondary:hover {
|
|
117
|
-
background: #f3f4f6;
|
|
118
|
-
border-color: #b1b9c2;
|
|
119
|
-
}
|
|
120
|
-
.message {
|
|
121
|
-
padding: 1rem;
|
|
122
|
-
border-radius: 6px;
|
|
123
|
-
margin-bottom: 1rem;
|
|
124
|
-
display: none;
|
|
125
|
-
}
|
|
126
|
-
.message.success {
|
|
127
|
-
background: #dafbe1;
|
|
128
|
-
color: #1a7f37;
|
|
129
|
-
border: 1px solid #1a7f37;
|
|
130
|
-
}
|
|
131
|
-
.message.error {
|
|
132
|
-
background: #ffebe9;
|
|
133
|
-
color: #cf222e;
|
|
134
|
-
border: 1px solid #cf222e;
|
|
135
|
-
}
|
|
136
|
-
.spinner {
|
|
137
|
-
display: none;
|
|
138
|
-
border: 2px solid #f3f4f6;
|
|
139
|
-
border-top: 2px solid #cf222e;
|
|
140
|
-
border-radius: 50%;
|
|
141
|
-
width: 16px;
|
|
142
|
-
height: 16px;
|
|
143
|
-
animation: spin 0.6s linear infinite;
|
|
144
|
-
margin: 0 auto;
|
|
145
|
-
}
|
|
146
|
-
@keyframes spin {
|
|
147
|
-
0% { transform: rotate(0deg); }
|
|
148
|
-
100% { transform: rotate(360deg); }
|
|
149
|
-
}
|
|
150
|
-
</style>
|
|
151
|
-
</head>
|
|
152
|
-
<body>
|
|
153
|
-
<div class="container">
|
|
154
|
-
<h1>Unsubscribe from Emails</h1>
|
|
155
|
-
<div id="message" class="message"></div>
|
|
156
|
-
<div id="content">
|
|
157
|
-
<p>Are you sure you want to unsubscribe from updates?</p>
|
|
158
|
-
<div class="buttons">
|
|
159
|
-
<button class="btn-secondary" onclick="window.close()">Cancel</button>
|
|
160
|
-
<button class="btn-primary" onclick="handleUnsubscribe()">Unsubscribe</button>
|
|
161
|
-
</div>
|
|
162
|
-
</div>
|
|
163
|
-
<div id="spinner" class="spinner"></div>
|
|
164
|
-
</div>
|
|
165
|
-
<script>
|
|
166
|
-
${params}
|
|
167
|
-
|
|
168
|
-
async function handleUnsubscribe() {
|
|
169
|
-
const content = document.getElementById('content');
|
|
170
|
-
const spinner = document.getElementById('spinner');
|
|
171
|
-
const message = document.getElementById('message');
|
|
172
|
-
|
|
173
|
-
content.style.display = 'none';
|
|
174
|
-
spinner.style.display = 'block';
|
|
175
|
-
|
|
176
|
-
try {
|
|
177
|
-
const response = await fetch('/api/email/unsubscribe', {
|
|
178
|
-
method: 'POST',
|
|
179
|
-
headers: { 'Content-Type': 'application/json' },
|
|
180
|
-
body: JSON.stringify({ token })
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const data = await response.json();
|
|
184
|
-
spinner.style.display = 'none';
|
|
185
|
-
|
|
186
|
-
if (data.success) {
|
|
187
|
-
message.className = 'message success';
|
|
188
|
-
message.textContent = data.message || 'You have been unsubscribed successfully.';
|
|
189
|
-
message.style.display = 'block';
|
|
190
|
-
} else {
|
|
191
|
-
message.className = 'message error';
|
|
192
|
-
message.textContent = data.message || 'Failed to unsubscribe. Please try again.';
|
|
193
|
-
message.style.display = 'block';
|
|
194
|
-
content.style.display = 'block';
|
|
195
|
-
}
|
|
196
|
-
} catch (error) {
|
|
197
|
-
spinner.style.display = 'none';
|
|
198
|
-
message.className = 'message error';
|
|
199
|
-
message.textContent = 'Network error. Please try again.';
|
|
200
|
-
message.style.display = 'block';
|
|
201
|
-
content.style.display = 'block';
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
</script>
|
|
205
|
-
</body>
|
|
206
|
-
</html>
|
|
207
|
-
`;
|
|
43
|
+
<head>
|
|
44
|
+
<meta charset="utf-8">
|
|
45
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
46
|
+
<title>Hintergrund Admin</title>
|
|
47
|
+
<meta name="description" content="Admin Panel for Hintergrund">
|
|
48
|
+
<link rel="icon" type="image/svg+xml" href="${faviconSvg}">
|
|
49
|
+
<style>* { box-sizing: border-box; margin: 0; padding: 0; } body { margin: 0; height: 100vh; }</style>
|
|
50
|
+
<link rel="stylesheet" href="${uiBaseUrl}/ui.css">
|
|
51
|
+
</head>
|
|
52
|
+
<body>
|
|
53
|
+
<hintergrund-admin ${params}></hintergrund-admin>
|
|
54
|
+
<script type="module" src="${uiBaseUrl}/admin.js"></script>
|
|
55
|
+
</body>
|
|
56
|
+
</html>`;
|
|
208
57
|
}
|
|
209
|
-
|
|
58
|
+
if (element === 'unsubscribe') {
|
|
59
|
+
return `
|
|
210
60
|
<!doctype html>
|
|
211
61
|
<html>
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
62
|
+
<head>
|
|
63
|
+
<meta charset="utf-8">
|
|
64
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
65
|
+
<title>Unsubscribe</title>
|
|
66
|
+
<link rel="icon" type="image/svg+xml" href="${faviconSvg}">
|
|
67
|
+
<style>
|
|
68
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
69
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f6f8fa; display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
|
|
70
|
+
.container { background: white; border-radius: 8px; border: 1px solid #d0d7de; padding: 2rem; max-width: 480px; width: 100%; }
|
|
71
|
+
h1 { font-size: 1.5rem; margin-bottom: 1rem; } p { color: #57606a; line-height: 1.5; margin-bottom: 1.5rem; }
|
|
72
|
+
.buttons { display: flex; gap: .75rem; } button { flex: 1; padding: .75rem 1rem; border-radius: 6px; border: 1px solid; cursor: pointer; }
|
|
73
|
+
.btn-primary { background: #cf222e; color: white; border-color: #cf222e; } .btn-secondary { background: #f6f8fa; color: #24292f; border-color: #d0d7de; }
|
|
74
|
+
.message { padding: 1rem; border-radius: 6px; margin-bottom: 1rem; display: none; } .message.success { background: #dafbe1; color: #1a7f37; border: 1px solid #1a7f37; } .message.error { background: #ffebe9; color: #cf222e; border: 1px solid #cf222e; }
|
|
75
|
+
.spinner { display: none; border: 2px solid #f3f4f6; border-top-color: #cf222e; border-radius: 50%; width: 16px; height: 16px; animation: spin .6s linear infinite; margin: 0 auto; } @keyframes spin { to { transform: rotate(360deg); } }
|
|
76
|
+
</style>
|
|
77
|
+
</head>
|
|
78
|
+
<body>
|
|
79
|
+
<div class="container"><h1>Unsubscribe from Emails</h1><div id="message" class="message"></div><div id="content"><p>Are you sure you want to unsubscribe from updates?</p><div class="buttons"><button class="btn-secondary" onclick="window.close()">Cancel</button><button class="btn-primary" onclick="handleUnsubscribe()">Unsubscribe</button></div></div><div id="spinner" class="spinner"></div></div>
|
|
80
|
+
<script>
|
|
81
|
+
${params}
|
|
82
|
+
async function handleUnsubscribe() {
|
|
83
|
+
const content = document.getElementById('content'), spinner = document.getElementById('spinner'), message = document.getElementById('message');
|
|
84
|
+
content.style.display = 'none'; spinner.style.display = 'block';
|
|
85
|
+
try {
|
|
86
|
+
const response = await fetch('/api/email/unsubscribe', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ token }) });
|
|
87
|
+
const data = await response.json(); spinner.style.display = 'none';
|
|
88
|
+
if (data.success) { message.className = 'message success'; message.textContent = data.message || 'You have been unsubscribed successfully.'; message.style.display = 'block'; }
|
|
89
|
+
else { message.className = 'message error'; message.textContent = data.message || 'Failed to unsubscribe. Please try again.'; message.style.display = 'block'; content.style.display = 'block'; }
|
|
90
|
+
} catch (error) { spinner.style.display = 'none'; message.className = 'message error'; message.textContent = 'Network error. Please try again.'; message.style.display = 'block'; content.style.display = 'block'; }
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
</body>
|
|
94
|
+
</html>`;
|
|
95
|
+
}
|
|
96
|
+
return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Hintergrund CMS</title><meta name="description" content="Admin Panel for Hintergrund CMS"><link rel="icon" type="image/svg+xml" href="${faviconSvg}"><style>body{margin:0}</style></head><body><${element} ${params}></${element}><script type="module" src="/index.js"></script></body></html>`;
|
|
226
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAMrC,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;;;;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAMrC,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI;;;;0FAsE1D"}
|
package/dist/middleware/auth.js
CHANGED
|
@@ -8,12 +8,13 @@ export async function authMiddleware(c, next) {
|
|
|
8
8
|
if (pathname === '/login' ||
|
|
9
9
|
pathname === '/api/admin/login' ||
|
|
10
10
|
pathname === '/api/admin/logout' ||
|
|
11
|
-
pathname === '/api/admin/verify-magic-link'
|
|
11
|
+
pathname === '/api/admin/verify-magic-link' ||
|
|
12
|
+
pathname === '/api/admin/setup') {
|
|
12
13
|
console.log('[AUTH MIDDLEWARE] Skipping auth for:', pathname);
|
|
13
14
|
return await next();
|
|
14
15
|
}
|
|
15
|
-
if (!c.env.
|
|
16
|
-
console.error('No configuration found. Set
|
|
16
|
+
if (!c.env.SECRET) {
|
|
17
|
+
console.error('No configuration found. Set SECRET');
|
|
17
18
|
if (pathname.startsWith('/api/')) {
|
|
18
19
|
return c.json({ error: 'Server configuration error' }, 500);
|
|
19
20
|
}
|
|
@@ -31,7 +32,7 @@ export async function authMiddleware(c, next) {
|
|
|
31
32
|
email: payload.email,
|
|
32
33
|
name: payload.name,
|
|
33
34
|
};
|
|
34
|
-
if (payload.userId &&
|
|
35
|
+
if (payload.userId && c.env.PROJECT_DB) {
|
|
35
36
|
const dbUser = await getAdminUserById(c.env, String(payload.userId));
|
|
36
37
|
if (!dbUser) {
|
|
37
38
|
if (pathname.startsWith('/api/')) {
|
package/package.json
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
2
|
+
"name": "@hintergrund/worker",
|
|
3
|
+
"version": "0.1.14",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@cloudflare/workers-types": "^4.20250111.0",
|
|
18
|
+
"concurrently": "^9.2.1",
|
|
19
|
+
"typescript": "^5.5.2",
|
|
20
|
+
"@hintergrund/runtime-contracts": "^0.1.9"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@hintergrund/auth": "^0.1.2",
|
|
24
|
+
"@octokit/rest": "^22.0.0",
|
|
25
|
+
"blakejs": "^1.2.1",
|
|
26
|
+
"cookie": "^1.0.2",
|
|
27
|
+
"hono": "^4.10.2",
|
|
28
|
+
"pdf-lib": "^1.17.1",
|
|
29
|
+
"stripe": "^17.5.0",
|
|
30
|
+
"tweetnacl": "^1.0.3"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc",
|
|
34
|
+
"dev": "tsc --watch"
|
|
35
|
+
}
|
|
36
|
+
}
|