From 1b4c10660384b983e1dcc4f779c8894fa82a7bc3 Mon Sep 17 00:00:00 2001 From: Darcy Ye Date: Mon, 15 Apr 2024 14:58:26 +0800 Subject: [PATCH] chore: add Cloudflare worker config for custom JWT (#5709) --- packages/schemas/src/types/system.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/schemas/src/types/system.ts b/packages/schemas/src/types/system.ts index ab9828afb..5813caffd 100644 --- a/packages/schemas/src/types/system.ts +++ b/packages/schemas/src/types/system.ts @@ -165,16 +165,35 @@ export const protectedAppConfigProviderDataGuard = z.object({ export type ProtectedAppConfigProviderData = z.infer; +/** + * Cloudflare workers config for custom JWT. + * Ref: https://developers.cloudflare.com/api/ + */ +export const customJwtWorkerConfigGuard = z.object({ + /** Cloudflare API Key (api_key). */ + apiKey: z.string(), + /** Cloudflare API Key (api_email). */ + apiEmail: z.string(), + /** Cloudflare account ID. */ + accountId: z.string(), + /** Default Cloudflare subdomain for the account. */ + subdomain: z.string(), +}); + +export type CustomJwtWorkerConfig = z.infer; + export enum CloudflareKey { HostnameProvider = 'cloudflareHostnameProvider', ProtectedAppConfigProvider = 'cloudflareProtectedAppConfigProvider', ProtectedAppHostnameProvider = 'cloudflareProtectedAppHostnameProvider', + CustomJwtWorkerConfig = 'cloudflareCustomJwtWorkerConfig', } export type CloudflareType = { [CloudflareKey.HostnameProvider]: HostnameProviderData; [CloudflareKey.ProtectedAppConfigProvider]: ProtectedAppConfigProviderData; [CloudflareKey.ProtectedAppHostnameProvider]: HostnameProviderData; + [CloudflareKey.CustomJwtWorkerConfig]: CustomJwtWorkerConfig; }; export const cloudflareGuard: Readonly<{ @@ -183,6 +202,7 @@ export const cloudflareGuard: Readonly<{ [CloudflareKey.HostnameProvider]: hostnameProviderDataGuard, [CloudflareKey.ProtectedAppConfigProvider]: protectedAppConfigProviderDataGuard, [CloudflareKey.ProtectedAppHostnameProvider]: hostnameProviderDataGuard, + [CloudflareKey.CustomJwtWorkerConfig]: customJwtWorkerConfigGuard, }); // Summary