fix: define globals for context

This commit is contained in:
Aarnav Tale
2025-03-11 21:58:25 -04:00
parent 296e4d489c
commit e36352b7f3
3 changed files with 24 additions and 7 deletions
+2 -2
View File
@@ -105,8 +105,8 @@ const headscaleConfig = type({
magic_dns: goBool.default(true),
base_domain: 'string = "headscale.net"',
nameservers: type({
'global?': 'string[]',
'split': type('Record<string, string[]>').default(() => ({})),
global: type('string[]').default(() => []),
split: type('Record<string, string[]>').default(() => ({})),
}).default(() => ({ global: [], split: {} })),
search_domains: type('string[]').default(() => []),
extra_records: type({
+1 -5
View File
@@ -6,10 +6,6 @@ import log from '~server/utils/log';
type OidcConfig = NonNullable<AppContext['context']['oidc']>;
declare global {
const __PREFIX__: string;
const __oidc_context: {
valid: boolean;
secret: string;
};
}
// We try our best to infer the callback URI of our Headplane instance
@@ -260,7 +256,7 @@ export function formatError(error: unknown) {
}
export function oidcEnabled() {
return __oidc_valid;
return __oidc_context.valid;
}
export async function testOidc(oidc: OidcConfig) {
+21
View File
@@ -0,0 +1,21 @@
import { HeadplaneConfig } from './parser';
declare global {
const __cookie_context: {
cookie_secret: string;
cookie_secure: boolean;
};
const __hs_context: {
url: string;
config_path?: string;
config_strict?: boolean;
};
const __oidc_context: {
valid: boolean;
secret: string;
};
let __integration_context: HeadplaneConfig['integration'];
}