/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CertificateParsed, CertificateParsed$inboundSchema, } from "./certificateparsed.js"; import { CertificateRevocation, CertificateRevocation$inboundSchema, } from "./certificaterevocation.js"; import { Ct, Ct$inboundSchema } from "./ct.js"; import { Validation, Validation$inboundSchema } from "./validation.js"; import { ZLint, ZLint$inboundSchema } from "./zlint.js"; export const ParseStatus = { Unknown: "", Success: "success", Fail: "fail", Corrupted: "corrupted", } as const; export type ParseStatus = OpenEnum; /** * The extent to which the certificate's issuer validated the identity of the entity requesting the certificate. Options include Domain validated (DV), Organization Validated (OV), or Extended Validation (EV). */ export const ValidationLevel = { Unknown: "", Dv: "dv", Ov: "ov", Ev: "ev", } as const; /** * The extent to which the certificate's issuer validated the identity of the entity requesting the certificate. Options include Domain validated (DV), Organization Validated (OV), or Extended Validation (EV). */ export type ValidationLevel = OpenEnum; export type Certificate = { /** * When the certificate was added to the Censys dataset. */ addedAt?: string | undefined; ct?: Ct | undefined; /** * Whether the certificate has ever been presented by a service during a scan. */ everSeenInScan?: boolean | undefined; /** * The MD-5 digest of the entire raw certificate. An identifier used by some systems. */ fingerprintMd5?: string | undefined; /** * The SHA-1 digest of the entire raw certificate. An identifier used by some systems. */ fingerprintSha1?: string | undefined; /** * The SHA-256 digest of the entire raw certificate. Its unique identifier, which Censys uses to index certificates records. */ fingerprintSha256?: string | undefined; /** * When the certificate record was last modified. */ modifiedAt?: string | undefined; /** * All the names contained in the certificate from various fields. */ names?: Array | null | undefined; /** * DEPRECATED: Use parent_spki_subject_fingerprint_sha256 */ parentSpkiFingerprintSha256?: string | undefined; /** * The SHA-256 digest of the parent certificate's DER-encoded SubjectPublicKeyInfo concatenated with its Subject. */ parentSpkiSubjectFingerprintSha256?: string | undefined; parseStatus?: ParseStatus | undefined; parsed?: CertificateParsed | undefined; /** * Whether the X.509 "poison" extension (OID: 1.3.6.1.4.1.11129.2.4.3) is marked critical, which prohibits the pre-certificate from being trusted. */ precert?: boolean | undefined; revocation?: CertificateRevocation | undefined; /** * Whether the certificate has been revoked before its expiry date by the issuer. */ revoked?: boolean | undefined; /** * DEPRECATED: Use spki_subject_fingerprint_sha256 */ spkiFingerprintSha256?: string | undefined; /** * The SHA-256 digest of the certificate's DER-encoded SubjectPublicKeyInfo concatenated with its Subject. */ spkiSubjectFingerprintSha256?: string | undefined; /** * The SHA-256 digest of the unsigned certificate's contents. */ tbsFingerprintSha256?: string | undefined; /** * The SHA-256 digest of the unsigned certificate with the CT Poison extension removed, if present. This represents the shared contents of a certificate and its corresponding pre-certificate. */ tbsNoCtFingerprintSha256?: string | undefined; /** * When the certificate record's trust was last checked. */ validatedAt?: string | undefined; validation?: Validation | undefined; /** * The extent to which the certificate's issuer validated the identity of the entity requesting the certificate. Options include Domain validated (DV), Organization Validated (OV), or Extended Validation (EV). */ validationLevel?: ValidationLevel | undefined; zlint?: ZLint | undefined; }; /** @internal */ export const ParseStatus$inboundSchema: z.ZodType< ParseStatus, z.ZodTypeDef, unknown > = openEnums.inboundSchema(ParseStatus); /** @internal */ export const ValidationLevel$inboundSchema: z.ZodType< ValidationLevel, z.ZodTypeDef, unknown > = openEnums.inboundSchema(ValidationLevel); /** @internal */ export const Certificate$inboundSchema: z.ZodType< Certificate, z.ZodTypeDef, unknown > = z.object({ added_at: z.string().optional(), ct: Ct$inboundSchema.optional(), ever_seen_in_scan: z.boolean().optional(), fingerprint_md5: z.string().optional(), fingerprint_sha1: z.string().optional(), fingerprint_sha256: z.string().optional(), modified_at: z.string().optional(), names: z.nullable(z.array(z.string())).optional(), parent_spki_fingerprint_sha256: z.string().optional(), parent_spki_subject_fingerprint_sha256: z.string().optional(), parse_status: ParseStatus$inboundSchema.optional(), parsed: CertificateParsed$inboundSchema.optional(), precert: z.boolean().optional(), revocation: CertificateRevocation$inboundSchema.optional(), revoked: z.boolean().optional(), spki_fingerprint_sha256: z.string().optional(), spki_subject_fingerprint_sha256: z.string().optional(), tbs_fingerprint_sha256: z.string().optional(), tbs_no_ct_fingerprint_sha256: z.string().optional(), validated_at: z.string().optional(), validation: Validation$inboundSchema.optional(), validation_level: ValidationLevel$inboundSchema.optional(), zlint: ZLint$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "added_at": "addedAt", "ever_seen_in_scan": "everSeenInScan", "fingerprint_md5": "fingerprintMd5", "fingerprint_sha1": "fingerprintSha1", "fingerprint_sha256": "fingerprintSha256", "modified_at": "modifiedAt", "parent_spki_fingerprint_sha256": "parentSpkiFingerprintSha256", "parent_spki_subject_fingerprint_sha256": "parentSpkiSubjectFingerprintSha256", "parse_status": "parseStatus", "spki_fingerprint_sha256": "spkiFingerprintSha256", "spki_subject_fingerprint_sha256": "spkiSubjectFingerprintSha256", "tbs_fingerprint_sha256": "tbsFingerprintSha256", "tbs_no_ct_fingerprint_sha256": "tbsNoCtFingerprintSha256", "validated_at": "validatedAt", "validation_level": "validationLevel", }); }); export function certificateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Certificate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Certificate' from JSON`, ); }