@hintergrund/worker 0.2.2 → 0.2.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/dist/api/cms/handlers/admin-users.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/admin-users.handler.js +5 -0
- package/dist/api/cms/handlers/agent-conversations.handler.d.ts +0 -1
- package/dist/api/cms/handlers/agent-conversations.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/agent-conversations.handler.js +0 -7
- package/dist/api/cms/handlers/agent-provider.handler.d.ts +12 -0
- package/dist/api/cms/handlers/agent-provider.handler.d.ts.map +1 -0
- package/dist/api/cms/handlers/agent-provider.handler.js +64 -0
- package/dist/api/cms/handlers/auth.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/auth.handler.js +42 -10
- package/dist/api/cms/handlers/dashboard.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/dashboard.handler.js +2 -3
- package/dist/api/cms/handlers/github-secrets.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/github-secrets.handler.js +4 -0
- package/dist/api/cms/handlers/setup.handler.d.ts.map +1 -1
- package/dist/api/cms/handlers/setup.handler.js +36 -12
- package/dist/api/cms/routes/index.d.ts.map +1 -1
- package/dist/api/cms/routes/index.js +4 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/lib/config.d.ts +5 -11
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +21 -36
- package/dist/lib/project-db.d.ts +2 -0
- package/dist/lib/project-db.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -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;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,
|
|
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,CAqC3E;AAED,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAiB5E"}
|
|
@@ -68,6 +68,11 @@ export async function patchAdminUser(c) {
|
|
|
68
68
|
const passwordHash = body.password
|
|
69
69
|
? await hashPw(String(body.password), c.env.SECRET ?? '')
|
|
70
70
|
: (body.passwordHash === undefined ? existing.password_hash : body.passwordHash);
|
|
71
|
+
// The owner's password is the way back in when email delivery fails, so it can be
|
|
72
|
+
// changed but never removed.
|
|
73
|
+
if (existing.initial_admin === 1 && !passwordHash) {
|
|
74
|
+
return c.json({ error: 'The site owner must keep a password.' }, 400);
|
|
75
|
+
}
|
|
71
76
|
const now = nowSeconds();
|
|
72
77
|
await db
|
|
73
78
|
.prepare(`UPDATE admin_users
|
|
@@ -3,5 +3,4 @@ import type { HonoEnv } from '../../../index';
|
|
|
3
3
|
export declare function listConversations(c: Context<HonoEnv>): Promise<Response>;
|
|
4
4
|
export declare function upsertConversation(c: Context<HonoEnv>): Promise<Response>;
|
|
5
5
|
export declare function deleteConversation(c: Context<HonoEnv>): Promise<Response>;
|
|
6
|
-
export declare function getAgentApiKey(c: Context<HonoEnv>): Promise<Response>;
|
|
7
6
|
//# sourceMappingURL=agent-conversations.handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-conversations.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/agent-conversations.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA4B9C,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAY9E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8C/E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAW/E
|
|
1
|
+
{"version":3,"file":"agent-conversations.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/agent-conversations.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA4B9C,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAY9E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8C/E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAW/E"}
|
|
@@ -85,10 +85,3 @@ export async function deleteConversation(c) {
|
|
|
85
85
|
.run();
|
|
86
86
|
return c.json({ success: true });
|
|
87
87
|
}
|
|
88
|
-
export async function getAgentApiKey(c) {
|
|
89
|
-
const apiKey = c.env.GEMINI_API_KEY?.trim();
|
|
90
|
-
if (!apiKey) {
|
|
91
|
-
return c.json({ error: 'Builder agent is not configured' }, 500);
|
|
92
|
-
}
|
|
93
|
-
return c.json({ apiKey });
|
|
94
|
-
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import { type AgentProviderName } from '@hintergrund/runtime-contracts';
|
|
3
|
+
import type { Bindings, HonoEnv } from '../../../index';
|
|
4
|
+
/** The provider to use, in declaration order, for projects that configure several. */
|
|
5
|
+
export declare function activeAgentProvider(env: Bindings): AgentProviderName | null;
|
|
6
|
+
export declare function getAgentConfig(c: Context<HonoEnv>): Promise<Response>;
|
|
7
|
+
/**
|
|
8
|
+
* Streams an agent request through to the configured provider. The browser speaks
|
|
9
|
+
* the provider's own protocol, so the body is forwarded verbatim both ways.
|
|
10
|
+
*/
|
|
11
|
+
export declare function proxyAgentRequest(c: Context<HonoEnv>): Promise<Response>;
|
|
12
|
+
//# sourceMappingURL=agent-provider.handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-provider.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/agent-provider.handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAA2C,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACjH,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AA4BxD,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,QAAQ,GAAG,iBAAiB,GAAG,IAAI,CAE3E;AAED,wBAAsB,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE3E;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CA8B9E"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AGENT_PROVIDERS, AGENT_PROVIDER_SECRETS } from '@hintergrund/runtime-contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Where each provider's requests go, and how its key is presented. Provider keys
|
|
4
|
+
* are Worker secrets and never reach the browser: the admin agents run in the
|
|
5
|
+
* client and call `/api/admin/agent/llm/*`, which attaches the key here.
|
|
6
|
+
*/
|
|
7
|
+
const PROVIDER_ENDPOINTS = {
|
|
8
|
+
google: {
|
|
9
|
+
baseUrl: 'https://generativelanguage.googleapis.com/v1beta',
|
|
10
|
+
authorize: (headers, key) => headers.set('x-goog-api-key', key),
|
|
11
|
+
},
|
|
12
|
+
deepseek: {
|
|
13
|
+
baseUrl: 'https://api.deepseek.com',
|
|
14
|
+
authorize: (headers, key) => headers.set('authorization', `Bearer ${key}`),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
function providerKey(env, provider) {
|
|
18
|
+
const value = env[AGENT_PROVIDER_SECRETS[provider]];
|
|
19
|
+
if (typeof value !== 'string')
|
|
20
|
+
return undefined;
|
|
21
|
+
const key = value.trim();
|
|
22
|
+
return key && key !== 'NOT_CONFIGURED' ? key : undefined;
|
|
23
|
+
}
|
|
24
|
+
/** The provider to use, in declaration order, for projects that configure several. */
|
|
25
|
+
export function activeAgentProvider(env) {
|
|
26
|
+
return AGENT_PROVIDERS.find((provider) => providerKey(env, provider)) ?? null;
|
|
27
|
+
}
|
|
28
|
+
export async function getAgentConfig(c) {
|
|
29
|
+
return c.json({ provider: activeAgentProvider(c.env) });
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Streams an agent request through to the configured provider. The browser speaks
|
|
33
|
+
* the provider's own protocol, so the body is forwarded verbatim both ways.
|
|
34
|
+
*/
|
|
35
|
+
export async function proxyAgentRequest(c) {
|
|
36
|
+
const provider = activeAgentProvider(c.env);
|
|
37
|
+
if (!provider)
|
|
38
|
+
return c.json({ error: 'No AI provider is configured for this project.' }, 503);
|
|
39
|
+
const { baseUrl, authorize } = PROVIDER_ENDPOINTS[provider];
|
|
40
|
+
const headers = new Headers();
|
|
41
|
+
for (const name of ['content-type', 'accept']) {
|
|
42
|
+
const value = c.req.header(name);
|
|
43
|
+
if (value)
|
|
44
|
+
headers.set(name, value);
|
|
45
|
+
}
|
|
46
|
+
authorize(headers, providerKey(c.env, provider));
|
|
47
|
+
const { search } = new URL(c.req.url);
|
|
48
|
+
const upstream = await fetch(`${baseUrl}/${c.req.param('path')}${search}`, {
|
|
49
|
+
method: c.req.method,
|
|
50
|
+
headers,
|
|
51
|
+
body: c.req.raw.body,
|
|
52
|
+
// The Workers runtime requires this when forwarding a streaming request body.
|
|
53
|
+
duplex: 'half',
|
|
54
|
+
signal: c.req.raw.signal,
|
|
55
|
+
});
|
|
56
|
+
// Pass the upstream body straight through so tokens reach the UI as they arrive.
|
|
57
|
+
return new Response(upstream.body, {
|
|
58
|
+
status: upstream.status,
|
|
59
|
+
headers: {
|
|
60
|
+
'content-type': upstream.headers.get('content-type') ?? 'application/json',
|
|
61
|
+
'cache-control': 'no-store',
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -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;AAgBzC,wBAAsB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,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;AAgBzC,wBAAsB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqBlE;AAsHD,wBAAsB,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAOnE"}
|
|
@@ -14,6 +14,8 @@ export async function login(c) {
|
|
|
14
14
|
const user = await getAdminUserByEmail(c.env, email);
|
|
15
15
|
if (!user)
|
|
16
16
|
return loginError('Invalid credentials', 401);
|
|
17
|
+
// A stored password stays valid as a fallback: an OTP admin can still sign in when
|
|
18
|
+
// email delivery breaks (expired provider key, changed DNS, provider outage).
|
|
17
19
|
if (body.password)
|
|
18
20
|
return await handleProjectPasswordLogin(c, body.password, appConfig.global.hgSecret, user, isSecure);
|
|
19
21
|
if (user.login_method === 'password') {
|
|
@@ -26,11 +28,22 @@ export async function login(c) {
|
|
|
26
28
|
return loginError('Unable to sign in. Try again.', 401);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
31
|
+
/** The project owner keeps a password fallback; other admins do not. */
|
|
32
|
+
function ownerHasPasswordFallback(user) {
|
|
33
|
+
return user.initial_admin === 1 && !!user.password_hash;
|
|
34
|
+
}
|
|
29
35
|
function loginError(message, status) {
|
|
30
36
|
return new Response(JSON.stringify({ success: false, message }), { status });
|
|
31
37
|
}
|
|
32
38
|
async function handleProjectPasswordLogin(c, password, hgSecret, user, isSecure) {
|
|
33
|
-
|
|
39
|
+
// The owner always keeps their password as a fallback, so a broken email provider
|
|
40
|
+
// cannot lock the project out. Other admins use only their chosen method, so a
|
|
41
|
+
// forgotten password never lingers as a live credential.
|
|
42
|
+
const ownerFallback = user.initial_admin === 1 && !!user.password_hash;
|
|
43
|
+
if (!ownerFallback && user.login_method !== 'password') {
|
|
44
|
+
return loginError('Password sign-in is not enabled for this user', 400);
|
|
45
|
+
}
|
|
46
|
+
if (!user.password_hash)
|
|
34
47
|
return loginError('Password sign-in is not enabled for this user', 400);
|
|
35
48
|
if (!(await verifyPw(user.password_hash, password, hgSecret)))
|
|
36
49
|
return loginError('Invalid credentials', 401);
|
|
@@ -40,8 +53,15 @@ async function handleProjectEmailOtpLogin(c, otp, user, appConfig, isSecure) {
|
|
|
40
53
|
if (user.login_method !== 'otp')
|
|
41
54
|
return loginError('Email-code sign-in is not enabled for this user', 400);
|
|
42
55
|
const emailsConfig = appConfig.emails;
|
|
43
|
-
if (!emailsConfig?.emailApiKey)
|
|
44
|
-
return
|
|
56
|
+
if (!emailsConfig?.emailApiKey) {
|
|
57
|
+
return c.json({
|
|
58
|
+
success: false,
|
|
59
|
+
requirePassword: ownerHasPasswordFallback(user),
|
|
60
|
+
message: ownerHasPasswordFallback(user)
|
|
61
|
+
? 'Email codes are unavailable for this project. Sign in with your password instead.'
|
|
62
|
+
: 'Email codes are unavailable because no email provider is configured for this project.',
|
|
63
|
+
}, 503);
|
|
64
|
+
}
|
|
45
65
|
const db = await ensureSchema(c.env);
|
|
46
66
|
const now = nowSeconds();
|
|
47
67
|
const submittedOtp = otp?.trim();
|
|
@@ -64,13 +84,25 @@ async function handleProjectEmailOtpLogin(c, otp, user, appConfig, isSecure) {
|
|
|
64
84
|
VALUES (?, ?, ?, ?, NULL, ?)`).bind(createId('otp'), user.id, codeHash, now + 15 * 60, now),
|
|
65
85
|
]);
|
|
66
86
|
const { settings } = await import('../../emails/handlers/settings.handler').then(({ readEmailSettings }) => readEmailSettings(c.env));
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
try {
|
|
88
|
+
await sendEmailOtp({
|
|
89
|
+
to: user.email,
|
|
90
|
+
apiKey: emailsConfig.emailApiKey,
|
|
91
|
+
fromEmail: settings.fromEmail ?? '',
|
|
92
|
+
fromName: settings.fromName,
|
|
93
|
+
code,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error('Sign-in code delivery failed:', error);
|
|
98
|
+
return c.json({
|
|
99
|
+
success: false,
|
|
100
|
+
requirePassword: ownerHasPasswordFallback(user),
|
|
101
|
+
message: ownerHasPasswordFallback(user)
|
|
102
|
+
? 'We could not send your sign-in code. Sign in with your password instead, then check the email provider settings.'
|
|
103
|
+
: 'We could not send your sign-in code. Ask the site owner to check the email provider settings.',
|
|
104
|
+
}, 503);
|
|
105
|
+
}
|
|
74
106
|
return c.json({ success: true, otpRequired: true, message: 'Check your email for a six-digit sign-in code.' });
|
|
75
107
|
}
|
|
76
108
|
function emailOtp() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/dashboard.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"dashboard.handler.d.ts","sourceRoot":"","sources":["../../../../src/api/cms/handlers/dashboard.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAWxF"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { getTemplate } from '../../../lib/template';
|
|
2
|
-
import {
|
|
2
|
+
import { getAdminConfig } from '../../../lib/config';
|
|
3
3
|
export async function getDashboard(c) {
|
|
4
4
|
try {
|
|
5
|
-
const
|
|
6
|
-
const adminConfig = getAdminConfig(appConfig);
|
|
5
|
+
const adminConfig = getAdminConfig();
|
|
7
6
|
const configParams = `config='${JSON.stringify(adminConfig)}'`;
|
|
8
7
|
return c.html(getTemplate('admin', c.env.UI_BASE_URL, configParams));
|
|
9
8
|
}
|
|
@@ -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;
|
|
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;AA4C9C,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"}
|
|
@@ -12,11 +12,15 @@ const DEPLOYABLE_ACTION_SECRET_NAMES = new Set([
|
|
|
12
12
|
'STRIPE_WEBHOOK_SECRET',
|
|
13
13
|
'API_KEY',
|
|
14
14
|
'SETUP_TOKEN',
|
|
15
|
+
'GEMINI_API_KEY',
|
|
16
|
+
'DEEPSEEK_API_KEY',
|
|
15
17
|
]);
|
|
16
18
|
const DELETABLE_ACTION_SECRET_NAMES = new Set([
|
|
17
19
|
'STRIPE_SECRET_KEY',
|
|
18
20
|
'STRIPE_WEBHOOK_SECRET',
|
|
19
21
|
'API_KEY',
|
|
22
|
+
'GEMINI_API_KEY',
|
|
23
|
+
'DEEPSEEK_API_KEY',
|
|
20
24
|
]);
|
|
21
25
|
function secretName(value) {
|
|
22
26
|
const name = value.trim();
|
|
@@ -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;
|
|
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;AAUpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAwB9C,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,CA+IzE;AAED,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E"}
|
|
@@ -6,6 +6,8 @@ import { readJsonConfig, writeJsonConfig } from '../../../lib/github-config';
|
|
|
6
6
|
import { DEFAULT_EMAIL_SETTINGS, EMAIL_SETTINGS_PATH } from '../../emails/handlers/settings.handler';
|
|
7
7
|
import Stripe from 'stripe';
|
|
8
8
|
import { createId, ensureSchema, issueSessionForUser, nowSeconds } from '../../../lib/project-db';
|
|
9
|
+
import { resolveModuleDependencies } from '@hintergrund/runtime-contracts';
|
|
10
|
+
const WEBSITE_SETUP_PATH = 'frontend/src/lib/website/setup.json';
|
|
9
11
|
const SHOP_SETTINGS_PATH = 'frontend/src/lib/shop/settings.json';
|
|
10
12
|
const DEFAULT_SHOP_SETTINGS = {
|
|
11
13
|
currency: 'eur',
|
|
@@ -56,29 +58,40 @@ export async function setupProject(c) {
|
|
|
56
58
|
if (!(await hasValidSetupToken(c.env, body.setupToken)))
|
|
57
59
|
return c.json({ error: 'Invalid setup link.' }, 403);
|
|
58
60
|
const email = typeof body.email === 'string' ? body.email.trim().toLowerCase() : '';
|
|
59
|
-
|
|
61
|
+
// Modules chosen during setup decide which of the remaining answers are required.
|
|
62
|
+
const requestedModules = typeof body.modules === 'object' && body.modules !== null ? body.modules : {};
|
|
63
|
+
const modules = resolveModuleDependencies({
|
|
64
|
+
shop: requestedModules.shop !== false,
|
|
65
|
+
emails: requestedModules.emails !== false,
|
|
66
|
+
});
|
|
67
|
+
// The owner signs in with email codes when the project sends email, but always sets a
|
|
68
|
+
// password too: it is the way back in if email delivery ever fails.
|
|
69
|
+
const loginMethod = modules.emails ? 'otp' : 'password';
|
|
70
|
+
const MIN_PASSWORD_LENGTH = 12;
|
|
60
71
|
const password = typeof body.password === 'string' ? body.password : '';
|
|
61
72
|
const plunkApiKey = typeof body.plunkApiKey === 'string' ? body.plunkApiKey.trim() : '';
|
|
62
73
|
const fromEmail = typeof body.fromEmail === 'string' ? body.fromEmail.trim() : '';
|
|
63
74
|
const paymentProvider = body.paymentProvider === 'stripe' || body.paymentProvider === 'bank_transfer' ? body.paymentProvider : null;
|
|
64
|
-
if (!email
|
|
65
|
-
return c.json({ error: 'An email address
|
|
66
|
-
if (
|
|
67
|
-
return c.json({ error:
|
|
68
|
-
if (loginMethod === 'otp' && (!plunkApiKey || !fromEmail)) {
|
|
69
|
-
return c.json({ error: 'Configure Plunk and a sender email to use email codes.' }, 400);
|
|
75
|
+
if (!email)
|
|
76
|
+
return c.json({ error: 'An email address is required.' }, 400);
|
|
77
|
+
if (password.length < MIN_PASSWORD_LENGTH) {
|
|
78
|
+
return c.json({ error: `Choose a password of at least ${MIN_PASSWORD_LENGTH} characters.` }, 400);
|
|
70
79
|
}
|
|
71
|
-
if (!
|
|
80
|
+
if (modules.emails && (!plunkApiKey || !fromEmail)) {
|
|
81
|
+
return c.json({ error: 'An email provider API key and sender address are required.' }, 400);
|
|
82
|
+
}
|
|
83
|
+
if (modules.shop && !paymentProvider)
|
|
72
84
|
return c.json({ error: 'Choose a payment provider.' }, 400);
|
|
73
85
|
const bankTransfer = typeof body.bankTransfer === 'object' && body.bankTransfer !== null ? body.bankTransfer : {};
|
|
74
86
|
const accountHolder = typeof bankTransfer.accountHolder === 'string' ? bankTransfer.accountHolder.trim() : '';
|
|
75
87
|
const iban = typeof bankTransfer.iban === 'string' ? bankTransfer.iban.trim() : '';
|
|
76
88
|
const stripeSecretKey = paymentProvider === 'stripe' && typeof body.stripeSecretKey === 'string' ? body.stripeSecretKey.trim() : '';
|
|
77
|
-
if (paymentProvider === 'bank_transfer' && (!accountHolder || !iban)) {
|
|
89
|
+
if (modules.shop && paymentProvider === 'bank_transfer' && (!accountHolder || !iban)) {
|
|
78
90
|
return c.json({ error: 'An account holder and IBAN are required for bank transfers.' }, 400);
|
|
79
91
|
}
|
|
80
|
-
if (paymentProvider === 'stripe' && !stripeSecretKey)
|
|
92
|
+
if (modules.shop && paymentProvider === 'stripe' && !stripeSecretKey) {
|
|
81
93
|
return c.json({ error: 'Your Stripe secret key is required for card payments.' }, 400);
|
|
94
|
+
}
|
|
82
95
|
// Do not consume the one-time setup route until GitHub is reachable. A project
|
|
83
96
|
// without its repository cannot complete setup and must remain retryable.
|
|
84
97
|
let client;
|
|
@@ -97,7 +110,9 @@ export async function setupProject(c) {
|
|
|
97
110
|
email,
|
|
98
111
|
name: null,
|
|
99
112
|
login_method: loginMethod,
|
|
100
|
-
|
|
113
|
+
// Always stored, including for an email-code owner: this is the fallback credential.
|
|
114
|
+
password_hash: await hashPw(password, c.env.SECRET ?? ''),
|
|
115
|
+
initial_admin: 1,
|
|
101
116
|
disabled_at: null,
|
|
102
117
|
created_at: now,
|
|
103
118
|
updated_at: now,
|
|
@@ -134,11 +149,20 @@ export async function setupProject(c) {
|
|
|
134
149
|
secrets[name] = value;
|
|
135
150
|
}
|
|
136
151
|
await Promise.all(Object.entries(secrets).map(([secretName, value]) => client.setActionsSecret(secretName, value)));
|
|
152
|
+
const { data: setupState, commitSha: setupCommitSha } = await readJsonConfig(client, WEBSITE_SETUP_PATH, {});
|
|
153
|
+
await writeJsonConfig(client, WEBSITE_SETUP_PATH, {
|
|
154
|
+
...setupState,
|
|
155
|
+
version: 1,
|
|
156
|
+
modules,
|
|
157
|
+
updatedAt: Date.now(),
|
|
158
|
+
}, 'Record enabled modules [skip ci]', setupCommitSha);
|
|
137
159
|
const { data: shopSettings, commitSha: shopCommitSha } = await readJsonConfig(client, SHOP_SETTINGS_PATH, DEFAULT_SHOP_SETTINGS);
|
|
138
160
|
await writeJsonConfig(client, SHOP_SETTINGS_PATH, {
|
|
139
161
|
...DEFAULT_SHOP_SETTINGS,
|
|
140
162
|
...shopSettings,
|
|
141
|
-
|
|
163
|
+
// No shop means no payment method was chosen; leave it empty rather than
|
|
164
|
+
// implying the shipped default was a decision.
|
|
165
|
+
enabledPaymentMethods: modules.shop && paymentProvider ? [paymentProvider] : [],
|
|
142
166
|
bankTransfer: {
|
|
143
167
|
...DEFAULT_SHOP_SETTINGS.bankTransfer,
|
|
144
168
|
...(shopSettings.bankTransfer ?? {}),
|
|
@@ -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;AAoB5B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,QAAA,MAAM,SAAS,sDAAsB,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;AAoB5B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,QAAA,MAAM,SAAS,sDAAsB,CAAC;AAgCtC,eAAe,SAAS,CAAC"}
|
|
@@ -3,7 +3,8 @@ import { getDashboard } from '../handlers/dashboard.handler';
|
|
|
3
3
|
import { authMiddleware } from '../../../middleware/auth';
|
|
4
4
|
import authRoutes from './auth.routes';
|
|
5
5
|
import { createAdminUser, deleteAdminUser, listAdminUsers, patchAdminUser } from '../handlers/admin-users.handler';
|
|
6
|
-
import { deleteConversation,
|
|
6
|
+
import { deleteConversation, listConversations, upsertConversation } from '../handlers/agent-conversations.handler';
|
|
7
|
+
import { getAgentConfig, proxyAgentRequest } from '../handlers/agent-provider.handler';
|
|
7
8
|
import { commitWebsiteRepo, headWebsiteRepo, syncWebsiteRepo, uploadWebsiteAsset } from '../handlers/website-repo.handler';
|
|
8
9
|
import { getWebsiteTemplateFile, getWebsiteTemplateManifest, listWebsiteTemplates } from '../handlers/website-templates.handler';
|
|
9
10
|
import { deleteGitHubSecret, listGitHubSecrets, upsertGitHubSecret } from '../handlers/github-secrets.handler';
|
|
@@ -24,7 +25,8 @@ cmsRoutes.delete('/users/:id', deleteAdminUser);
|
|
|
24
25
|
cmsRoutes.get('/agent/conversations', listConversations);
|
|
25
26
|
cmsRoutes.post('/agent/conversations', upsertConversation);
|
|
26
27
|
cmsRoutes.delete('/agent/conversations/:id', deleteConversation);
|
|
27
|
-
cmsRoutes.get('/agent/
|
|
28
|
+
cmsRoutes.get('/agent/config', getAgentConfig);
|
|
29
|
+
cmsRoutes.all('/agent/llm/:path{.+}', proxyAgentRequest);
|
|
28
30
|
cmsRoutes.get('/website/repo/head', headWebsiteRepo);
|
|
29
31
|
cmsRoutes.get('/website/repo/sync', syncWebsiteRepo);
|
|
30
32
|
cmsRoutes.put('/website/repo/commit', commitWebsiteRepo);
|
package/dist/index.d.ts
CHANGED
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;AAW5B,MAAM,MAAM,QAAQ,GAAG;IAEtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAG7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAA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AAM,OAAO,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AAEnE,wBAAgB,SAAS,yDA2GxB;AAGD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -72,16 +72,16 @@ export function createApp() {
|
|
|
72
72
|
}
|
|
73
73
|
// Get admin configuration
|
|
74
74
|
try {
|
|
75
|
-
const {
|
|
76
|
-
const
|
|
77
|
-
const adminConfig = getAdminConfig(
|
|
75
|
+
const { getAdminConfig } = await import('./lib/config');
|
|
76
|
+
const { activeAgentProvider } = await import('./api/cms/handlers/agent-provider.handler');
|
|
77
|
+
const adminConfig = getAdminConfig();
|
|
78
78
|
adminConfig.canManageAdminUsers = true;
|
|
79
79
|
adminConfig.integrations = {
|
|
80
80
|
stripePublishableKeySet: !!c.env.STRIPE_PUBLISHABLE_KEY,
|
|
81
81
|
stripeSecretKeySet: !!c.env.STRIPE_SECRET_KEY && c.env.STRIPE_SECRET_KEY !== 'NOT_CONFIGURED',
|
|
82
82
|
stripeWebhookSecretSet: !!c.env.STRIPE_WEBHOOK_SECRET && c.env.STRIPE_WEBHOOK_SECRET !== 'NOT_CONFIGURED',
|
|
83
83
|
emailProviderApiKeySet: !!(c.env.API_KEY || c.env.PLUNK_SECRET_KEY),
|
|
84
|
-
|
|
84
|
+
agentProvider: activeAgentProvider(c.env),
|
|
85
85
|
};
|
|
86
86
|
const configParams = `config='${JSON.stringify(adminConfig)}'`;
|
|
87
87
|
return c.html(getTemplate('admin', c.env.UI_BASE_URL, configParams));
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -5,19 +5,13 @@ import type { AppConfig, AdminConfig, EmailsModuleConfig, ShopModuleConfig } fro
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function loadConfig(env: Record<string, string | undefined> | any): AppConfig;
|
|
7
7
|
/**
|
|
8
|
-
* Get admin UI configuration.
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
export declare function getAdminConfig(_appConfig: AppConfig): AdminConfig;
|
|
12
|
-
/**
|
|
13
|
-
* Get Emails module configuration
|
|
14
|
-
* @throws Error if Emails module is not enabled
|
|
8
|
+
* Get admin UI configuration. Every module ships with provisioning; the newsletter
|
|
9
|
+
* is toggled in email settings.
|
|
15
10
|
*/
|
|
11
|
+
export declare function getAdminConfig(): AdminConfig;
|
|
12
|
+
/** Get Emails module configuration. */
|
|
16
13
|
export declare function getEmailsConfig(env: Record<string, string | undefined> | any): EmailsModuleConfig;
|
|
17
|
-
/**
|
|
18
|
-
* Get Shop module configuration
|
|
19
|
-
* @throws Error if Shop module is not enabled
|
|
20
|
-
*/
|
|
14
|
+
/** Get Shop module configuration. */
|
|
21
15
|
export declare function getShopConfig(env: Record<string, string | undefined> | any): ShopModuleConfig;
|
|
22
16
|
/**
|
|
23
17
|
* Get GitHub configuration from environment variables
|
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,kBAAkB,EAAE,gBAAgB,EAAe,MAAM,gCAAgC,CAAC;AAEhI;;;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,kBAAkB,EAAE,gBAAgB,EAAe,MAAM,gCAAgC,CAAC;AAEhI;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,SAAS,CAOnF;AAyCD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAI5C;AAED,uCAAuC;AACvC,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,kBAAkB,CAEjG;AAED,qCAAqC;AACrC,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,gBAAgB,CAE7F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,GAAG;oBAUX,MAAM;mBAA+B,MAAM;cANhF,MAAM;aACR,MAAM;;;iBAWG,MAAM;0BACY,MAAM;sBACV,MAAM;cAd3B,MAAM;aACR,MAAM;;EAehC"}
|
package/dist/lib/config.js
CHANGED
|
@@ -26,56 +26,41 @@ function getMissingVars(env, requiredVars) {
|
|
|
26
26
|
const GIT_REPOSITORY_VARS = ['GIT_OWNER', 'GIT_REPO'];
|
|
27
27
|
const GITHUB_APP_VARS = ['GITHUB_APP_ID', 'GITHUB_INSTALLATION_ID', 'GITHUB_APP_PRIVATE_KEY'];
|
|
28
28
|
function loadFromEnvVars(env) {
|
|
29
|
-
|
|
29
|
+
return {
|
|
30
30
|
global: {
|
|
31
31
|
hgSecret: env.SECRET || '',
|
|
32
32
|
},
|
|
33
|
+
emails: {
|
|
34
|
+
emailProvider: 'plunk',
|
|
35
|
+
emailApiKey: env.API_KEY || env.PLUNK_SECRET_KEY || '',
|
|
36
|
+
fromEmail: '',
|
|
37
|
+
fromName: '',
|
|
38
|
+
replyTo: undefined,
|
|
39
|
+
},
|
|
40
|
+
shop: {
|
|
41
|
+
paymentProvider: env.STRIPE_SECRET_KEY ? 'stripe' : 'bank_transfer',
|
|
42
|
+
stripeSecretKey: env.STRIPE_SECRET_KEY,
|
|
43
|
+
stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET,
|
|
44
|
+
stripePublishableKey: env.STRIPE_PUBLISHABLE_KEY,
|
|
45
|
+
},
|
|
33
46
|
};
|
|
34
|
-
config.emails = {
|
|
35
|
-
emailProvider: 'plunk',
|
|
36
|
-
emailApiKey: env.API_KEY || env.PLUNK_SECRET_KEY || '',
|
|
37
|
-
fromEmail: '',
|
|
38
|
-
fromName: '',
|
|
39
|
-
replyTo: undefined,
|
|
40
|
-
};
|
|
41
|
-
config.shop = {
|
|
42
|
-
paymentProvider: env.STRIPE_SECRET_KEY ? 'stripe' : 'bank_transfer',
|
|
43
|
-
stripeSecretKey: env.STRIPE_SECRET_KEY,
|
|
44
|
-
stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET,
|
|
45
|
-
stripePublishableKey: env.STRIPE_PUBLISHABLE_KEY,
|
|
46
|
-
};
|
|
47
|
-
return config;
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
|
-
* Get admin UI configuration.
|
|
51
|
-
*
|
|
49
|
+
* Get admin UI configuration. Every module ships with provisioning; the newsletter
|
|
50
|
+
* is toggled in email settings.
|
|
52
51
|
*/
|
|
53
|
-
export function getAdminConfig(
|
|
52
|
+
export function getAdminConfig() {
|
|
54
53
|
return {
|
|
55
54
|
loginMethod: 'password',
|
|
56
55
|
};
|
|
57
56
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Get Emails module configuration
|
|
60
|
-
* @throws Error if Emails module is not enabled
|
|
61
|
-
*/
|
|
57
|
+
/** Get Emails module configuration. */
|
|
62
58
|
export function getEmailsConfig(env) {
|
|
63
|
-
|
|
64
|
-
if (!config.emails) {
|
|
65
|
-
throw new Error('Emails module is not enabled');
|
|
66
|
-
}
|
|
67
|
-
return config.emails;
|
|
59
|
+
return loadConfig(env).emails;
|
|
68
60
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Get Shop module configuration
|
|
71
|
-
* @throws Error if Shop module is not enabled
|
|
72
|
-
*/
|
|
61
|
+
/** Get Shop module configuration. */
|
|
73
62
|
export function getShopConfig(env) {
|
|
74
|
-
|
|
75
|
-
if (!config.shop) {
|
|
76
|
-
throw new Error('Shop module is not enabled');
|
|
77
|
-
}
|
|
78
|
-
return config.shop;
|
|
63
|
+
return loadConfig(env).shop;
|
|
79
64
|
}
|
|
80
65
|
/**
|
|
81
66
|
* Get GitHub configuration from environment variables
|
package/dist/lib/project-db.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface AdminUser {
|
|
|
6
6
|
name: string | null;
|
|
7
7
|
password_hash: string | null;
|
|
8
8
|
login_method: LoginMethod;
|
|
9
|
+
/** 1 for the project owner created during setup, null for everyone else. */
|
|
10
|
+
initial_admin: number | null;
|
|
9
11
|
disabled_at: number | null;
|
|
10
12
|
created_at: number;
|
|
11
13
|
updated_at: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-db.d.ts","sourceRoot":"","sources":["../../src/lib/project-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,KAAK,CAAC;AAE7C,MAAM,WAAW,SAAS;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,WAAW,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACnB;AAKD,eAAO,MAAM,kBAAkB,u7IAgH9B,CAAC;AAEF,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,GAAG,UAAU,CAMtD;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO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AAY,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAUrE;AAGD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOpE;AAED,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAMjG;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAM/F;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hintergrund/worker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@cloudflare/workers-types": "^4.20250111.0",
|
|
22
22
|
"concurrently": "^9.2.1",
|
|
23
|
-
"typescript": "^5.5.2"
|
|
24
|
-
"@hintergrund/runtime-contracts": "^0.2.2"
|
|
23
|
+
"typescript": "^5.5.2"
|
|
25
24
|
},
|
|
26
25
|
"dependencies": {
|
|
27
26
|
"@hintergrund/auth": "^0.1.2",
|
|
27
|
+
"@hintergrund/runtime-contracts": "^0.2.3",
|
|
28
28
|
"@octokit/rest": "^22.0.0",
|
|
29
29
|
"blakejs": "^1.2.1",
|
|
30
30
|
"cookie": "^1.0.2",
|