Scratch space for learning atproto app development
1import { Jwk, jwkValidator } from '@atproto/oauth-client-node'
2import { makeValidator } from 'envalid'
3import { z } from 'zod'
4
5export type JsonWebKey = Jwk & { kid: string }
6
7const jsonWebKeySchema = z.intersection(
8 jwkValidator,
9 z.object({ kid: z.string().nonempty() }),
10) satisfies z.ZodType<JsonWebKey>
11
12const jsonWebKeysSchema = z.array(jsonWebKeySchema).nonempty()
13
14export const envalidJsonWebKeys = makeValidator((input) => {
15 const value = JSON.parse(input)
16 return jsonWebKeysSchema.parse(value)
17})