import {z} from 'zod' export type JwkTypeRsa = {keySize?: number | undefined, keyUseType?: ('SIGNATURE' | 'ENCRYPTION') | undefined, algorithm?: ('RSA256' | 'RSA384' | 'RSA512' | 'PS256' | 'PS384' | 'PS512' | 'RSA1_5' | 'RSA_OAEP' | 'RSA_OAEP_256' | 'RSA_OAEP_384' | 'RSA_OAEP_512') | undefined, keyIdType?: ('TIMESTAMP' | 'SHA256' | 'SHA1' | 'ISO_DATE' | 'NONE') | undefined, notBeforeTime?: string | undefined, expirationTime?: string | undefined, revoked?: boolean | undefined}; export type JwkTypeEc = {curveType?: ('P256' | 'P384' | 'P521' | 'SECP256K1') | undefined, keyUseType?: ('SIGNATURE' | 'ENCRYPTION') | undefined, algorithm?: ('ES256' | 'ES384' | 'ES512' | 'ES256K' | 'ECDH_ES' | 'ECDH_ES_A128KW' | 'ECDH_ES_A192KW' | 'ECDH_ES_A256KW' | 'ECDH_1PU' | 'ECDH_1PU_A128KW' | 'ECDH_1PU_A192KW' | 'ECDH_1PU_A256KW') | undefined, keyIdType?: ('TIMESTAMP' | 'SHA256' | 'SHA1' | 'ISO_DATE' | 'NONE') | undefined, notBeforeTime?: string | undefined, expirationTime?: string | undefined, revoked?: boolean | undefined}; export type JwkTypeOct = {keySize?: number | undefined, keyUseType?: ('SIGNATURE' | 'ENCRYPTION') | undefined, algorithm?: ('HS256' | 'HS384' | 'HS512' | 'A128KW' | 'A192KW' | 'A256KW' | 'A128GCMKW' | 'A192GCMKW' | 'A256GCMKW' | 'DIR' | 'PBES2_HS256_A128KW' | 'PBES2_HS384_A192KW' | 'PBES2_HS512_A256KW') | undefined, keyIdType?: ('TIMESTAMP' | 'SHA256' | 'SHA1' | 'ISO_DATE' | 'NONE') | undefined, passwordSaltLength?: number | undefined, passwordIterationCount?: number | undefined, notBeforeTime?: string | undefined, expirationTime?: string | undefined, revoked?: boolean | undefined}; export type JwkTypeOkp = {curveType?: ('ED25519' | 'X25519') | undefined, keyUseType?: ('SIGNATURE' | 'ENCRYPTION') | undefined, algorithm?: ('EdDSA' | 'ECDH_ES' | 'ECDH_ES_A128KW' | 'ECDH_ES_A192KW' | 'ECDH_ES_A256KW' | 'ECDH_1PU' | 'ECDH_1PU_A128KW' | 'ECDH_1PU_A192KW' | 'ECDH_1PU_A256KW') | undefined, keyIdType?: ('TIMESTAMP' | 'SHA256' | 'SHA1' | 'ISO_DATE' | 'NONE') | undefined, notBeforeTime?: string | undefined, expirationTime?: string | undefined, revoked?: boolean | undefined}; export type JwkCreateDTO = {name?: string | undefined, description?: string | undefined, sourceType?: ('GENERATE' | 'URL' | 'COPY_PASTE' | 'CERTIFICATE' | 'PUBLIC_KEY' | 'PRIVATE_KEY' | 'KEYSTORE' | 'AUTO_DETECT') | undefined, sourceId?: string | undefined, sourceUrl?: string | undefined, type?: ('RSA' | 'EC' | 'OCT' | 'OKP') | undefined, kid?: string | undefined, url?: string | undefined, urlOptionConnectTimeout?: number | undefined, urlOptionReadTimeout?: number | undefined, urlOptionSizeLimit?: number | undefined, jwkStr?: string | undefined, certificateName?: string | undefined, keyName?: string | undefined, keyStoreName?: string | undefined, environmentName?: string | undefined, aliasName?: string | undefined, useType?: ('SIGNATURE' | 'ENCRYPTION') | undefined, algorithm?: string | undefined, rsa?: JwkTypeRsa | undefined, ec?: JwkTypeEc | undefined, oct?: JwkTypeOct | undefined, okp?: JwkTypeOkp | undefined}; export type CreateApiApiopsProjectsProjectNameJwksParseFromClipboardArgs = {projectName: string, body: JwkCreateDTO}; export type CreateApiApiopsProjectsProjectNameJwksParseFromClipboardOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const deploymentResult = z.object({envName: z.string().optional(), podName: z.string().optional(), podIp: z.string().optional(), success: z.boolean().optional(), detail: z.string().optional(), responseTime: z.number().int().optional(), detailList: z.array(z.unknown()).optional(), firstFromApiResultList: z.unknown()}); export const apiOpsAdvisoryDTO = z.object({level: z.string().optional(), key: z.string().optional(), params: z.record(z.string(), z.unknown()).optional()}); export const apiOpsResponseSuccess = z.object({status: z.enum(["SUCCESS", "FAILURE"]).optional(), resultMessage: z.string().optional(), resultList: z.array(z.string()).optional(), resultCount: z.number().int().optional(), deploymentResult: deploymentResult.optional(), unresolvedReferences: z.array(z.string()).optional(), advisories: z.array(apiOpsAdvisoryDTO).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 }; /** * Parse JWK from Clipboard * * POST /apiops/projects/{projectName}/jwks/parse-from-clipboard */ export const createApiApiopsProjectsProjectNameJwksParseFromClipboard = async (args: CreateApiApiopsProjectsProjectNameJwksParseFromClipboardArgs, options?: CreateApiApiopsProjectsProjectNameJwksParseFromClipboardOptions) => { const {baseUrl = "http://167.86.118.166:32080", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/apiops/projects/${encodeURIComponent(String(args.projectName))}/jwks/parse-from-clipboard${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(apiOpsResponseSuccess, await res.json()) };