import {z} from 'zod' export type GetApiApiV1ValidationUserUserIdArgs = {userId: string, account_id: string}; export type GetApiApiV1ValidationUserUserIdOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const validationDetailsResponse = z.object({validation_status: z.enum(["VALIDATION_CREATED", "VALIDATION_ERROR", "INVITE_SENT", "INVITE_FAILED", "PENDING_IDENTITY_PROOFING", "APPROVED", "REJECTED", "ABORTED", "DOCUMENT_VERIFICATION_ERROR", "REVIEW_PENDING", "EXPIRED", "PENDING_MANUAL_REVIEW", "PENDING_SIGNER_APPROVAL", "PENDING_ORG_REVIEW", "DISABLED", "CANCELLED"]).optional(), validation_expiry_date: z.string().optional(), validation_type: z.enum(["advanced+", "qualified", "basic"]).optional(), terms_and_conditions: z.string().optional(), terms_id: z.string().optional(), certificate: z.object({subject_dn: z.string().optional(), validity: z.string().optional()}).optional(), default_profile_id: z.string().optional(), validation_id: z.string().optional(), validation_method: z.enum(["f2f", "remote", "RA", "manual", "remote_manual"]).optional(), ident_type: z.enum(["AUTO_IDENT_ADVANCED", "AUTO_IDENT_QUALIFIED", "VIDEO_IDENT_QUALIFIED", "AUTO_IDENT_BASIC", "VIDEO_IDENT_BASIC", "VIDEO_IDENT_ADVANCED_PLUS", "VIDEO_IDENT_TEST_QUALIFIED", "AUTO_IDENT_TEST_ADVANCED", "AUTO_IDENT_TEST_QUALIFIED", "AUTO_IDENT_TEST_BASIC", "VIDEO_IDENT_TEST_BASIC", "VIDEO_IDENT_TEST_ADVANCED_PLUS"]).optional(), ident_id: z.string().optional(), oauth_account_id: z.string().optional(), client_data: z.string().optional(), sli: z.string().optional()}); export const validationDetailListResponse = z.object({oauth_account_id: z.string().optional(), sli: z.string().optional(), bulk_onboarding_user_id: z.string().optional(), oauth_account_cert_central_enabled: z.string().optional(), validation_list: z.array(validationDetailsResponse).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Get user validation details * * GET /api/v1/validation/user/{userId} */ export const getApiApiV1ValidationUserUserId = async (args: GetApiApiV1ValidationUserUserIdArgs, options?: GetApiApiV1ValidationUserUserIdOptions) => { const {baseUrl = "https://one.digicert.com/documentmanager", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.account_id != null) query.append("account_id", String(args.account_id)) if (ApiKeyAuth !== undefined) headers.set("X-API-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/validation/user/${encodeURIComponent(String(args.userId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(validationDetailListResponse, await res.json()) };