mharj/mharj-jwt-util

View on GitHub
src/interfaces/CertRecords.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import {z} from 'zod';

const issuerUrl = z.string().url();

const keyId = z.string();

export const certIssuerRecordSchema = z.record(keyId, z.string().optional());

export type CertIssuerRecord = z.infer<typeof certIssuerRecordSchema>;

export const certRecordsSchema = z.object({
    _ts: z.number(),
    certs: z.record(issuerUrl, certIssuerRecordSchema),
});

export type CertRecords = z.infer<typeof certRecordsSchema>;

export function isCertRecords(obj: unknown): obj is CertRecords {
    return certRecordsSchema.safeParse(obj).success;
}