@hintergrund/worker 0.1.3 → 0.1.5
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/auth.handler.d.ts +4 -3
- package/dist/api/cms/handlers/auth.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/auth.handler.js +24 -14
- package/dist/api/cms/routes/auth.routes.d.ts +2 -1
- package/dist/api/cms/routes/auth.routes.d.ts.map +1 -1
- package/dist/api/cms/routes/auth.routes.js +7 -0
- package/dist/api/cms/routes/index.d.ts +2 -1
- package/dist/api/cms/routes/index.d.ts.map +1 -1
- package/dist/api/emails/handlers/webhook.handler.d.ts +10 -0
- package/dist/api/emails/handlers/webhook.handler.d.ts.map +1 -0
- package/dist/api/emails/handlers/webhook.handler.js +261 -0
- package/dist/api/emails/routes/public.routes.d.ts.map +1 -1
- package/dist/api/emails/routes/public.routes.js +3 -0
- package/dist/api/shop/routes.d.ts.map +1 -1
- package/dist/api/shop/routes.js +0 -3
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +6 -3
- package/dist/lib/email.d.ts +2 -2
- package/dist/lib/email.d.ts.map +1 -1
- package/dist/lib/email.js +7 -9
- package/dist/lib/plunk.d.ts +0 -3
- package/dist/lib/plunk.d.ts.map +1 -1
- package/dist/lib/plunk.js +1 -4
- package/package.json +32 -32
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Context } from 'hono';
|
|
2
|
+
import { HonoEnv } from '../../../index';
|
|
2
3
|
/**
|
|
3
4
|
* Handle login request - supports both password and magic link authentication
|
|
4
5
|
*/
|
|
5
|
-
export declare function login(c: Context): Promise<Response>;
|
|
6
|
+
export declare function login(c: Context<HonoEnv>): Promise<Response>;
|
|
6
7
|
/**
|
|
7
8
|
* Verify magic link token and log user in
|
|
8
9
|
*/
|
|
9
|
-
export declare function verifyMagicLink(c: Context): Promise<Response>;
|
|
10
|
-
export declare function logout(c: Context): Promise<Response>;
|
|
10
|
+
export declare function verifyMagicLink(c: Context<HonoEnv>): Promise<Response>;
|
|
11
|
+
export declare function logout(c: Context<HonoEnv>): Promise<Response>;
|
|
11
12
|
//# 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;
|
|
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;AAOzC;;GAEG;AACH,wBAAsB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqBlE;AAyMD;;GAEG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAuC5E;AAYD,wBAAsB,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWnE"}
|
|
@@ -96,12 +96,15 @@ async function handleMagicLinkLogin(c, body, appConfig, isSecure) {
|
|
|
96
96
|
return new Response(JSON.stringify({ success: false, message: 'Email is required' }), { status: 400 });
|
|
97
97
|
}
|
|
98
98
|
const authConfig = appConfig.global.auth;
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
const emailsConfig = appConfig.emails;
|
|
100
|
+
if (!emailsConfig?.plunkSecretKey || !emailsConfig?.enabled) {
|
|
101
|
+
return new Response(JSON.stringify({ success: false, message: 'Emails module is not configured' }), { status: 500 });
|
|
101
102
|
}
|
|
102
|
-
const userGroups = authConfig
|
|
103
|
+
const userGroups = authConfig?.userGroups;
|
|
104
|
+
const allowedEmails = authConfig?.allowedEmails;
|
|
103
105
|
// Find which group(s) this email belongs to
|
|
104
106
|
let matchedGroup;
|
|
107
|
+
let isAllowed = false;
|
|
105
108
|
if (userGroups && userGroups.length > 0) {
|
|
106
109
|
if (userGroupName) {
|
|
107
110
|
// User specified a group - verify email is in that group
|
|
@@ -109,23 +112,31 @@ async function handleMagicLinkLogin(c, body, appConfig, isSecure) {
|
|
|
109
112
|
if (!group) {
|
|
110
113
|
return new Response(JSON.stringify({ success: false, message: 'Invalid user group' }), { status: 401 });
|
|
111
114
|
}
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return new Response(JSON.stringify(response), { status: 200 });
|
|
115
|
+
if (group.emails?.includes(email)) {
|
|
116
|
+
matchedGroup = group;
|
|
117
|
+
isAllowed = true;
|
|
116
118
|
}
|
|
117
|
-
matchedGroup = group;
|
|
118
119
|
}
|
|
119
120
|
else {
|
|
120
121
|
// Find any group that contains this email
|
|
121
122
|
matchedGroup = userGroups.find(g => g.emails?.includes(email));
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
const response = { success: true, emailSent: true, message: 'If your email is registered, you will receive a login link.' };
|
|
125
|
-
return new Response(JSON.stringify(response), { status: 200 });
|
|
123
|
+
if (matchedGroup) {
|
|
124
|
+
isAllowed = true;
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
}
|
|
128
|
+
else {
|
|
129
|
+
// No user groups - check whitelist
|
|
130
|
+
if (allowedEmails && allowedEmails.includes(email)) {
|
|
131
|
+
isAllowed = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (!isAllowed) {
|
|
135
|
+
// Don't reveal which emails are valid - just say email sent
|
|
136
|
+
// This applies to both missing from whitelist and missing from user groups
|
|
137
|
+
const response = { success: true, emailSent: true, message: 'If your email is registered, you will receive a login link.' };
|
|
138
|
+
return new Response(JSON.stringify(response), { status: 200 });
|
|
139
|
+
}
|
|
129
140
|
// Generate magic link token (valid for 15 minutes)
|
|
130
141
|
const magicToken = await signWithPayload(appConfig.global.hgSecret, {
|
|
131
142
|
email,
|
|
@@ -140,8 +151,7 @@ async function handleMagicLinkLogin(c, body, appConfig, isSecure) {
|
|
|
140
151
|
try {
|
|
141
152
|
await sendMagicLinkEmail({
|
|
142
153
|
to: email,
|
|
143
|
-
|
|
144
|
-
resendApiKey: authConfig.resendApiKey,
|
|
154
|
+
plunkSecretKey: emailsConfig.plunkSecretKey,
|
|
145
155
|
magicLinkUrl,
|
|
146
156
|
userGroup: matchedGroup?.name,
|
|
147
157
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
|
|
2
|
+
import { HonoEnv } from '../../../index';
|
|
3
|
+
declare const authRoutes: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
|
|
3
4
|
export default authRoutes;
|
|
4
5
|
//# sourceMappingURL=auth.routes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/routes/auth.routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/routes/auth.routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,QAAA,MAAM,UAAU,sDAAsB,CAAC;AAavC,eAAe,UAAU,CAAC"}
|
|
@@ -3,5 +3,12 @@ import { login, logout, verifyMagicLink } from '../handlers/auth.handler';
|
|
|
3
3
|
const authRoutes = new Hono();
|
|
4
4
|
authRoutes.post('/login', login);
|
|
5
5
|
authRoutes.post('/logout', logout);
|
|
6
|
+
authRoutes.get('/me', (c) => {
|
|
7
|
+
const user = c.get('user');
|
|
8
|
+
if (user) {
|
|
9
|
+
return c.json({ success: true, user });
|
|
10
|
+
}
|
|
11
|
+
return c.json({ success: false, message: 'Not logged in' }, 401);
|
|
12
|
+
});
|
|
6
13
|
authRoutes.get('/verify-magic-link', verifyMagicLink);
|
|
7
14
|
export default authRoutes;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
|
-
|
|
2
|
+
import { HonoEnv } from '../../../index';
|
|
3
|
+
declare const cmsRoutes: Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
|
|
3
4
|
export default cmsRoutes;
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/routes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAM5B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,QAAA,MAAM,SAAS,sDAAsB,CAAC;AAatC,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { Bindings } from '../../../index';
|
|
3
|
+
/**
|
|
4
|
+
* POST /api/email/webhook
|
|
5
|
+
* Handle Stripe webhook events
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleStripeWebhook(c: Context<{
|
|
8
|
+
Bindings: Bindings;
|
|
9
|
+
}>): Promise<Response>;
|
|
10
|
+
//# sourceMappingURL=webhook.handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/handlers/webhook.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAkC/C;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsC/F"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { getShopConfig, getEmailsConfig, getGitHubConfig } from '../../../lib/config';
|
|
2
|
+
import { createGitHubClient } from '../../../lib/github';
|
|
3
|
+
import Stripe from 'stripe';
|
|
4
|
+
import { generateInvoicePdf } from './invoice.handler';
|
|
5
|
+
function getStripe(env) {
|
|
6
|
+
const config = getShopConfig(env);
|
|
7
|
+
return new Stripe(config.stripeSecretKey, {
|
|
8
|
+
apiVersion: '2025-02-24.acacia'
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
// Default invoice configuration
|
|
12
|
+
const DEFAULT_INVOICE_CONFIG = {
|
|
13
|
+
showLogo: true,
|
|
14
|
+
primaryColor: '#1f2937',
|
|
15
|
+
accentColor: '#3b82f6',
|
|
16
|
+
logoPosition: 'left',
|
|
17
|
+
fontFamily: 'helvetica',
|
|
18
|
+
companyName: 'Your Company',
|
|
19
|
+
companyAddress: '123 Main Street, City, Country',
|
|
20
|
+
companyEmail: 'contact@company.com',
|
|
21
|
+
companyPhone: '+1 234 567 890',
|
|
22
|
+
currencySymbol: '€',
|
|
23
|
+
currencyPosition: 'before',
|
|
24
|
+
showTaxBreakdown: true,
|
|
25
|
+
taxLabel: 'VAT',
|
|
26
|
+
taxRate: 19,
|
|
27
|
+
dueDays: 14,
|
|
28
|
+
footerText: 'Thank you for your business!'
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* POST /api/email/webhook
|
|
32
|
+
* Handle Stripe webhook events
|
|
33
|
+
*/
|
|
34
|
+
export async function handleStripeWebhook(c) {
|
|
35
|
+
const stripe = getStripe(c.env);
|
|
36
|
+
const webhookSecret = c.env.HG_SHOP_STRIPE_WEBHOOK_SECRET;
|
|
37
|
+
if (!webhookSecret) {
|
|
38
|
+
console.error('Stripe webhook secret not configured');
|
|
39
|
+
return c.json({ error: 'Webhook not configured' }, 500);
|
|
40
|
+
}
|
|
41
|
+
// Get the raw body and signature
|
|
42
|
+
const signature = c.req.header('stripe-signature');
|
|
43
|
+
if (!signature) {
|
|
44
|
+
return c.json({ error: 'Missing stripe-signature header' }, 400);
|
|
45
|
+
}
|
|
46
|
+
const rawBody = await c.req.text();
|
|
47
|
+
let event;
|
|
48
|
+
try {
|
|
49
|
+
event = await stripe.webhooks.constructEventAsync(rawBody, signature, webhookSecret);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
console.error('Webhook signature verification failed:', err.message);
|
|
53
|
+
return c.json({ error: 'Webhook signature verification failed' }, 400);
|
|
54
|
+
}
|
|
55
|
+
// Handle the event
|
|
56
|
+
switch (event.type) {
|
|
57
|
+
case 'checkout.session.completed': {
|
|
58
|
+
const session = event.data.object;
|
|
59
|
+
await handleCheckoutSessionCompleted(c, stripe, session);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
// Add more event handlers as needed
|
|
63
|
+
default:
|
|
64
|
+
console.log(`Unhandled event type: ${event.type}`);
|
|
65
|
+
}
|
|
66
|
+
return c.json({ received: true });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Handle checkout.session.completed event
|
|
70
|
+
* Generate and send invoice PDF to customer
|
|
71
|
+
*/
|
|
72
|
+
async function handleCheckoutSessionCompleted(c, stripe, session) {
|
|
73
|
+
try {
|
|
74
|
+
// Get customer email
|
|
75
|
+
const customerEmail = session.customer_details?.email;
|
|
76
|
+
if (!customerEmail) {
|
|
77
|
+
console.error('No customer email in checkout session');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Get line items
|
|
81
|
+
const lineItems = await stripe.checkout.sessions.listLineItems(session.id, {
|
|
82
|
+
expand: ['data.price.product']
|
|
83
|
+
});
|
|
84
|
+
// Get invoice template and branding from GitHub
|
|
85
|
+
let template;
|
|
86
|
+
let branding;
|
|
87
|
+
try {
|
|
88
|
+
const gitConfig = getGitHubConfig(c.env);
|
|
89
|
+
const github = createGitHubClient(gitConfig);
|
|
90
|
+
const settingsPath = `emails/settings.json`;
|
|
91
|
+
const result = await github.readJsonFile(settingsPath);
|
|
92
|
+
if (result?.data.invoice) {
|
|
93
|
+
template = result.data.invoice;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
template = {
|
|
97
|
+
id: 'invoice',
|
|
98
|
+
config: DEFAULT_INVOICE_CONFIG,
|
|
99
|
+
createdAt: Date.now(),
|
|
100
|
+
updatedAt: Date.now()
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (result?.data.branding) {
|
|
104
|
+
branding = result.data.branding;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
console.error('Failed to fetch settings from GitHub:', error);
|
|
109
|
+
template = {
|
|
110
|
+
id: 'invoice',
|
|
111
|
+
config: DEFAULT_INVOICE_CONFIG,
|
|
112
|
+
createdAt: Date.now(),
|
|
113
|
+
updatedAt: Date.now()
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// Build invoice data
|
|
117
|
+
const invoiceItems = lineItems.data.map((item) => {
|
|
118
|
+
const product = item.price?.product;
|
|
119
|
+
return {
|
|
120
|
+
description: product?.name || item.description || 'Item',
|
|
121
|
+
quantity: item.quantity || 1,
|
|
122
|
+
unitPrice: (item.price?.unit_amount || 0) / 100,
|
|
123
|
+
total: (item.amount_total || 0) / 100
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
const subtotal = (session.amount_subtotal || 0) / 100;
|
|
127
|
+
const tax = session.total_details?.amount_tax ? session.total_details.amount_tax / 100 : undefined;
|
|
128
|
+
const total = (session.amount_total || 0) / 100;
|
|
129
|
+
const invoiceData = {
|
|
130
|
+
invoiceNumber: `INV-${session.id.slice(-8).toUpperCase()}`,
|
|
131
|
+
invoiceDate: new Date().toLocaleDateString('en-US', {
|
|
132
|
+
year: 'numeric',
|
|
133
|
+
month: 'long',
|
|
134
|
+
day: 'numeric'
|
|
135
|
+
}),
|
|
136
|
+
customerName: session.customer_details?.name || 'Customer',
|
|
137
|
+
customerEmail,
|
|
138
|
+
customerAddress: session.customer_details?.address
|
|
139
|
+
? formatAddress(session.customer_details.address)
|
|
140
|
+
: undefined,
|
|
141
|
+
items: invoiceItems,
|
|
142
|
+
subtotal,
|
|
143
|
+
tax,
|
|
144
|
+
total,
|
|
145
|
+
currency: session.currency?.toUpperCase() || 'EUR',
|
|
146
|
+
paymentMethod: session.payment_method_types?.[0] || 'card'
|
|
147
|
+
};
|
|
148
|
+
// Generate PDF with branding
|
|
149
|
+
const pdfBytes = await generateInvoicePdf(template, invoiceData, branding ? {
|
|
150
|
+
logo: branding.logo,
|
|
151
|
+
companyName: branding.config.companyName,
|
|
152
|
+
primaryColor: branding.config.primaryColor,
|
|
153
|
+
} : undefined);
|
|
154
|
+
// Send email with PDF attachment
|
|
155
|
+
await sendInvoiceEmail(c, customerEmail, invoiceData, pdfBytes);
|
|
156
|
+
console.log(`Invoice sent to ${customerEmail} for session ${session.id}`);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
console.error('Failed to handle checkout session completed:', error);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Format Stripe address object to string
|
|
164
|
+
*/
|
|
165
|
+
function formatAddress(address) {
|
|
166
|
+
const parts = [];
|
|
167
|
+
if (address.line1)
|
|
168
|
+
parts.push(address.line1);
|
|
169
|
+
if (address.line2)
|
|
170
|
+
parts.push(address.line2);
|
|
171
|
+
if (address.city)
|
|
172
|
+
parts.push(address.city);
|
|
173
|
+
if (address.postal_code)
|
|
174
|
+
parts.push(address.postal_code);
|
|
175
|
+
if (address.country)
|
|
176
|
+
parts.push(address.country);
|
|
177
|
+
return parts.join(', ');
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Send invoice email with PDF attachment
|
|
181
|
+
*/
|
|
182
|
+
async function sendInvoiceEmail(c, to, invoiceData, pdfBytes) {
|
|
183
|
+
const emailsConfig = getEmailsConfig(c.env);
|
|
184
|
+
const apiKey = emailsConfig.plunkSecretKey;
|
|
185
|
+
const fromEmail = emailsConfig.fromEmail;
|
|
186
|
+
const fromName = emailsConfig.fromName || 'Shop';
|
|
187
|
+
if (!apiKey || !fromEmail) {
|
|
188
|
+
console.error('Email not configured');
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
// Convert PDF to base64 // Unused
|
|
192
|
+
// const pdfBase64 = btoa(String.fromCharCode(...pdfBytes));
|
|
193
|
+
// Build email HTML
|
|
194
|
+
const html = `
|
|
195
|
+
<div style="font-family: sans-serif; max-width: 600px; margin: 0 auto; padding: 20px;">
|
|
196
|
+
<h1 style="color: #1f2937;">Thank you for your purchase!</h1>
|
|
197
|
+
<p style="color: #4b5563;">Dear ${invoiceData.customerName},</p>
|
|
198
|
+
<p style="color: #4b5563;">Thank you for your order. Please find your invoice attached to this email.</p>
|
|
199
|
+
|
|
200
|
+
<div style="background-color: #f3f4f6; padding: 20px; border-radius: 8px; margin: 20px 0;">
|
|
201
|
+
<p style="margin: 0; color: #1f2937;"><strong>Invoice Number:</strong> ${invoiceData.invoiceNumber}</p>
|
|
202
|
+
<p style="margin: 8px 0; color: #1f2937;"><strong>Date:</strong> ${invoiceData.invoiceDate}</p>
|
|
203
|
+
<p style="margin: 8px 0; color: #1f2937;"><strong>Total:</strong> ${invoiceData.currency} ${invoiceData.total.toFixed(2)}</p>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<p style="color: #4b5563;">If you have any questions about your order, please don't hesitate to contact us.</p>
|
|
207
|
+
|
|
208
|
+
<p style="color: #9ca3af; font-size: 12px; margin-top: 40px;">
|
|
209
|
+
This is an automated email. Please do not reply directly to this message.
|
|
210
|
+
</p>
|
|
211
|
+
</div>
|
|
212
|
+
`;
|
|
213
|
+
// Send via Plunk API
|
|
214
|
+
// Note: PDF attachment support via Plunk JSON API might need verification,
|
|
215
|
+
// but preserving existing logic for now.
|
|
216
|
+
// Usually Plunk API uses 'attachments' field or different endpoint if supporting attachments.
|
|
217
|
+
// The previous code didn't actually attach the PDF in the fetch call payload?
|
|
218
|
+
// Wait, the previous code had `const pdfBase64 = ...` but didn't use it in payload.
|
|
219
|
+
// I will preserve exact behavior of previous code, but I suspect it was incomplete/buggy regarding attachment.
|
|
220
|
+
// User asked to move logic, not fix bugs, but I should probably mention it or fix it if obvious.
|
|
221
|
+
// Actually, let's look at the payload in previous file.
|
|
222
|
+
/*
|
|
223
|
+
const payload = {
|
|
224
|
+
to,
|
|
225
|
+
subject: `Your Invoice ${invoiceData.invoiceNumber}`,
|
|
226
|
+
body: html,
|
|
227
|
+
from: fromEmail,
|
|
228
|
+
name: fromName,
|
|
229
|
+
};
|
|
230
|
+
*/
|
|
231
|
+
// Indeed, pdfBase64 was calculated but not used.
|
|
232
|
+
// I will uncomment/use it to be helpful!
|
|
233
|
+
// Plunk API documentation isn't provided, but generally `attachments` array is common.
|
|
234
|
+
// However, without knowing Plunk API specs, adding it might break it if schema is strict.
|
|
235
|
+
// The user didn't ask to fix bugs. I will copy AS IS to minimize risk, but I'll update the comment.
|
|
236
|
+
// Actually, I'll keep the `pdfBase64` line commented out or just present as it was (calculated but unused)
|
|
237
|
+
// to match 1:1 the original logic.
|
|
238
|
+
// Original code:
|
|
239
|
+
// const pdfBase64 = btoa(String.fromCharCode(...pdfBytes));
|
|
240
|
+
// ...
|
|
241
|
+
// const payload = { ... } (no attachment)
|
|
242
|
+
const payload = {
|
|
243
|
+
to,
|
|
244
|
+
subject: `Your Invoice ${invoiceData.invoiceNumber}`,
|
|
245
|
+
body: html,
|
|
246
|
+
from: fromEmail,
|
|
247
|
+
name: fromName,
|
|
248
|
+
};
|
|
249
|
+
const response = await fetch('https://api.useplunk.com/v1/send', {
|
|
250
|
+
method: 'POST',
|
|
251
|
+
headers: {
|
|
252
|
+
Authorization: `Bearer ${apiKey}`,
|
|
253
|
+
'Content-Type': 'application/json'
|
|
254
|
+
},
|
|
255
|
+
body: JSON.stringify(payload)
|
|
256
|
+
});
|
|
257
|
+
if (!response.ok) {
|
|
258
|
+
const error = await response.text();
|
|
259
|
+
throw new Error(`Failed to send invoice email: ${error}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/routes/public.routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"public.routes.d.ts","sourceRoot":"","sources":["../../../../src/api/emails/routes/public.routes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAU5B,QAAA,MAAM,YAAY,4EAAa,CAAC;AAYhC,eAAe,YAAY,CAAC"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Hono } from 'hono';
|
|
7
7
|
import { subscribe, confirm, unsubscribe, showUnsubscribePage, trackEvent } from '../handlers/public.handler';
|
|
8
|
+
import { handleStripeWebhook } from '../handlers/webhook.handler';
|
|
8
9
|
const publicRoutes = new Hono();
|
|
9
10
|
// Public newsletter endpoints (no authentication required)
|
|
10
11
|
publicRoutes.post('/subscribe', subscribe);
|
|
@@ -12,4 +13,6 @@ publicRoutes.get('/confirm', confirm);
|
|
|
12
13
|
publicRoutes.get('/unsubscribe', showUnsubscribePage);
|
|
13
14
|
publicRoutes.post('/unsubscribe', unsubscribe);
|
|
14
15
|
publicRoutes.post('/track', trackEvent);
|
|
16
|
+
// Stripe webhook (no auth, but verified by signature)
|
|
17
|
+
publicRoutes.post('/webhook', handleStripeWebhook);
|
|
15
18
|
export default publicRoutes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/api/shop/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/api/shop/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAe5C,QAAA,MAAM,UAAU;cAAwB,QAAQ;yCAAK,CAAC;AAuBtD,eAAe,UAAU,CAAC"}
|
package/dist/api/shop/routes.js
CHANGED
|
@@ -5,13 +5,10 @@ import { getProducts, getProduct, createProduct, updateProduct, deleteProduct }
|
|
|
5
5
|
import { createPrice, updatePrice } from './handlers/prices.handler';
|
|
6
6
|
import { uploadShopAsset } from './handlers/assets.handler';
|
|
7
7
|
import { getPublicProducts, createCheckoutSession } from './handlers/public.handler';
|
|
8
|
-
import { handleStripeWebhook } from './handlers/webhook.handler';
|
|
9
8
|
const shopRoutes = new Hono();
|
|
10
9
|
// Public routes (no auth required)
|
|
11
10
|
shopRoutes.get('/products', getPublicProducts);
|
|
12
11
|
shopRoutes.post('/checkout', createCheckoutSession);
|
|
13
|
-
// Stripe webhook (no auth, but verified by signature)
|
|
14
|
-
shopRoutes.post('/webhook', handleStripeWebhook);
|
|
15
12
|
// Apply auth middleware to all shop admin routes
|
|
16
13
|
shopRoutes.use('/admin/*', authMiddleware);
|
|
17
14
|
// Assets
|
package/dist/index.d.ts
CHANGED
|
@@ -18,9 +18,18 @@ export type Bindings = {
|
|
|
18
18
|
UI_BASE_URL: string;
|
|
19
19
|
ASSETS: Fetcher;
|
|
20
20
|
};
|
|
21
|
-
export
|
|
21
|
+
export type Variables = {
|
|
22
|
+
user?: {
|
|
23
|
+
email: string;
|
|
24
|
+
userGroup?: string;
|
|
25
|
+
modules?: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type HonoEnv = {
|
|
22
29
|
Bindings: Bindings;
|
|
23
|
-
|
|
30
|
+
Variables: Variables;
|
|
31
|
+
};
|
|
32
|
+
export declare function createApp(): Hono<HonoEnv, import("hono/types").BlankSchema, "/">;
|
|
24
33
|
export * from './lib/auth/jwt';
|
|
25
34
|
export * from './lib/auth/crypto';
|
|
26
35
|
export * from './lib/template';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,MAAM,MAAM,QAAQ,GAAG;IAEtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAG5B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,8BAA8B,C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BAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,gBAAgB,EAAsC,MAAM,qBAAqB,CAAC;AAE7J;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,SAAS,CAOnF;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,gBAAgB,EAAsC,MAAM,qBAAqB,CAAC;AAE7J;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,SAAS,CAOnF;AAmHD;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW,CAQhE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,eAAe,CAQ3F;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,kBAAkB,CAQjG;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,gBAAgB,CAQ7F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CAClB,CAYA"}
|
package/dist/lib/config.js
CHANGED
|
@@ -53,10 +53,14 @@ function loadFromEnvVars(env) {
|
|
|
53
53
|
// Build auth configuration
|
|
54
54
|
const loginMethod = env.HG_AUTH_METHOD || 'password';
|
|
55
55
|
const userGroups = parseUserGroups(env);
|
|
56
|
+
// Parse allowed emails whitelist
|
|
57
|
+
const allowedEmailsRaw = env.HG_AUTH_ALLOWED_EMAILS;
|
|
58
|
+
const allowedEmails = allowedEmailsRaw
|
|
59
|
+
? allowedEmailsRaw.split(',').map((e) => e.trim()).filter((e) => e.length > 0)
|
|
60
|
+
: undefined;
|
|
56
61
|
const authConfig = env.HG_AUTH_METHOD ? {
|
|
57
62
|
loginMethod,
|
|
58
|
-
|
|
59
|
-
fromEmail: env.HG_AUTH_FROM_EMAIL,
|
|
63
|
+
allowedEmails,
|
|
60
64
|
userGroups,
|
|
61
65
|
} : undefined;
|
|
62
66
|
const config = {
|
|
@@ -86,7 +90,6 @@ function loadFromEnvVars(env) {
|
|
|
86
90
|
enabled: true,
|
|
87
91
|
plunkSecretKey: env.HG_EMAILS_PLUNK_SECRET_KEY || '',
|
|
88
92
|
plunkPublicKey: env.HG_EMAILS_PLUNK_PUBLIC_KEY,
|
|
89
|
-
plunkProjectName: env.HG_EMAILS_PLUNK_PROJECT,
|
|
90
93
|
fromEmail: env.HG_EMAILS_FROM_EMAIL || '',
|
|
91
94
|
fromName: env.HG_EMAILS_FROM_NAME || '',
|
|
92
95
|
replyTo: env.HG_EMAILS_REPLY_TO,
|
package/dist/lib/email.d.ts
CHANGED
package/dist/lib/email.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/lib/email.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,UAAU,mBAAmB;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/lib/email.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,UAAU,mBAAmB;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+EnF"}
|
package/dist/lib/email.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Send a magic link email for passwordless authentication
|
|
6
6
|
*/
|
|
7
7
|
export async function sendMagicLinkEmail(params) {
|
|
8
|
-
const { to,
|
|
8
|
+
const { to, plunkSecretKey, magicLinkUrl, userGroup } = params;
|
|
9
9
|
const subject = 'Sign in to hintergrund';
|
|
10
10
|
const groupInfo = userGroup ? ` as ${userGroup}` : '';
|
|
11
11
|
const html = `
|
|
@@ -52,7 +52,7 @@ export async function sendMagicLinkEmail(params) {
|
|
|
52
52
|
</body>
|
|
53
53
|
</html>
|
|
54
54
|
`;
|
|
55
|
-
const
|
|
55
|
+
const body = `
|
|
56
56
|
Sign in to hintergrund${groupInfo}
|
|
57
57
|
|
|
58
58
|
Click the link below to sign in. This link will expire in 15 minutes.
|
|
@@ -61,23 +61,21 @@ ${magicLinkUrl}
|
|
|
61
61
|
|
|
62
62
|
If you didn't request this email, you can safely ignore it.
|
|
63
63
|
`;
|
|
64
|
-
const response = await fetch('https://api.
|
|
64
|
+
const response = await fetch('https://api.useplunk.com/v1/send', {
|
|
65
65
|
method: 'POST',
|
|
66
66
|
headers: {
|
|
67
|
-
'Authorization': `Bearer ${
|
|
67
|
+
'Authorization': `Bearer ${plunkSecretKey}`,
|
|
68
68
|
'Content-Type': 'application/json',
|
|
69
69
|
},
|
|
70
70
|
body: JSON.stringify({
|
|
71
|
-
|
|
72
|
-
to: [to],
|
|
71
|
+
to,
|
|
73
72
|
subject,
|
|
74
|
-
html,
|
|
75
|
-
text,
|
|
73
|
+
body: html,
|
|
76
74
|
}),
|
|
77
75
|
});
|
|
78
76
|
if (!response.ok) {
|
|
79
77
|
const error = await response.text();
|
|
80
|
-
console.error('
|
|
78
|
+
console.error('Plunk API error:', error);
|
|
81
79
|
throw new Error(`Failed to send email: ${response.status}`);
|
|
82
80
|
}
|
|
83
81
|
}
|
package/dist/lib/plunk.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ import type { Contact, PlunkTemplate, PlunkCampaign } from '@hintergrund/shared'
|
|
|
12
12
|
interface PlunkConfig {
|
|
13
13
|
secretKey: string;
|
|
14
14
|
publicKey?: string;
|
|
15
|
-
projectName?: string;
|
|
16
15
|
}
|
|
17
16
|
interface PlunkContactResponse {
|
|
18
17
|
success: boolean;
|
|
@@ -53,7 +52,6 @@ export declare class PlunkClient {
|
|
|
53
52
|
private baseUrl;
|
|
54
53
|
private secretKey;
|
|
55
54
|
private publicKey?;
|
|
56
|
-
private projectName?;
|
|
57
55
|
constructor(config: PlunkConfig);
|
|
58
56
|
private request;
|
|
59
57
|
/**
|
|
@@ -201,7 +199,6 @@ export declare class PlunkClient {
|
|
|
201
199
|
export declare function createPlunkClient(env: {
|
|
202
200
|
HG_EMAILS_PLUNK_SECRET_KEY?: string;
|
|
203
201
|
HG_EMAILS_PLUNK_PUBLIC_KEY?: string;
|
|
204
|
-
HG_EMAILS_PLUNK_PROJECT?: string;
|
|
205
202
|
}): PlunkClient;
|
|
206
203
|
export {};
|
|
207
204
|
//# sourceMappingURL=plunk.d.ts.map
|
package/dist/lib/plunk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plunk.d.ts","sourceRoot":"","sources":["../../src/lib/plunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACX,OAAO,EACP,aAAa,EACb,aAAa,EACb,MAAM,qBAAqB,CAAC;AAE7B,UAAU,WAAW;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"plunk.d.ts","sourceRoot":"","sources":["../../src/lib/plunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACX,OAAO,EACP,aAAa,EACb,aAAa,EACb,MAAM,qBAAqB,CAAC;AAE7B,UAAU,WAAW;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAOD,UAAU,oBAAoB;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;CACpB;AAMD,UAAU,qBAAqB;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;CACX;AAMD,UAAU,qBAAqB;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAED,UAAU,kBAAkB;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACd;AAED,UAAU,iBAAiB;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,CAAC;QACd,OAAO,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACxB,KAAK,EAAE,MAAM,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class PlunkClient {
|
|
|
13
13
|
this.baseUrl = 'https://next-api.useplunk.com';
|
|
14
14
|
this.secretKey = config.secretKey;
|
|
15
15
|
this.publicKey = config.publicKey;
|
|
16
|
-
this.projectName = config.projectName;
|
|
17
16
|
}
|
|
18
17
|
async request(endpoint, options = {}, usePublicKey = false) {
|
|
19
18
|
const apiKey = usePublicKey && this.publicKey ? this.publicKey : this.secretKey;
|
|
@@ -29,8 +28,7 @@ export class PlunkClient {
|
|
|
29
28
|
if (!response.ok) {
|
|
30
29
|
const error = data;
|
|
31
30
|
// Enhanced error logging
|
|
32
|
-
|
|
33
|
-
console.error(`Plunk API Error${projectInfo}: ${error.error || error.message}`);
|
|
31
|
+
console.error(`Plunk API Error: ${error.error || error.message}`);
|
|
34
32
|
throw new Error(error.message || error.error || `Plunk API error: ${response.status}`);
|
|
35
33
|
}
|
|
36
34
|
return data;
|
|
@@ -257,6 +255,5 @@ export function createPlunkClient(env) {
|
|
|
257
255
|
return new PlunkClient({
|
|
258
256
|
secretKey: env.HG_EMAILS_PLUNK_SECRET_KEY,
|
|
259
257
|
publicKey: env.HG_EMAILS_PLUNK_PUBLIC_KEY,
|
|
260
|
-
projectName: env.HG_EMAILS_PLUNK_PROJECT,
|
|
261
258
|
});
|
|
262
259
|
}
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
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
|
-
}
|
|
2
|
+
"name": "@hintergrund/worker",
|
|
3
|
+
"version": "0.1.5",
|
|
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
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"dev": "tsc --watch"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@cloudflare/workers-types": "^4.20250111.0",
|
|
22
|
+
"concurrently": "^9.2.1",
|
|
23
|
+
"typescript": "^5.5.2"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@hintergrund/shared": "workspace:*",
|
|
27
|
+
"@octokit/rest": "^22.0.0",
|
|
28
|
+
"cookie": "^1.0.2",
|
|
29
|
+
"hono": "^4.10.2",
|
|
30
|
+
"pdf-lib": "^1.17.1",
|
|
31
|
+
"stripe": "^17.5.0"
|
|
32
|
+
}
|
|
33
|
+
}
|