Skip to content

Commit

Permalink
chore: add Cloudflare worker config for custom JWT (#5709)
Browse files Browse the repository at this point in the history
  • Loading branch information
darcyYe authored Apr 15, 2024
1 parent 622e003 commit 1b4c106
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/schemas/src/types/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,35 @@ export const protectedAppConfigProviderDataGuard = z.object({

export type ProtectedAppConfigProviderData = z.infer<typeof protectedAppConfigProviderDataGuard>;

/**
* 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<typeof customJwtWorkerConfigGuard>;

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<{
Expand All @@ -183,6 +202,7 @@ export const cloudflareGuard: Readonly<{
[CloudflareKey.HostnameProvider]: hostnameProviderDataGuard,
[CloudflareKey.ProtectedAppConfigProvider]: protectedAppConfigProviderDataGuard,
[CloudflareKey.ProtectedAppHostnameProvider]: hostnameProviderDataGuard,
[CloudflareKey.CustomJwtWorkerConfig]: customJwtWorkerConfigGuard,
});

// Summary
Expand Down

0 comments on commit 1b4c106

Please sign in to comment.